Skip to content

Commit c56d1f2

Browse files
authored
Merge pull request #48 from uparma/feature/drop_non_keys
keys without translations are set to None
2 parents 66aafc5 + c6ef83b commit c56d1f2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/test_back_and_forward_mappings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def test_simple_back_and_forward_mapping(test_id):
7171
for k, v in forward_mapping.items():
7272
if isinstance(v["translated_key"], list):
7373
continue
74+
if v["original_key"].endswith("<DROP_KEY>"):
75+
continue
76+
if v["translated_key"] is None:
77+
continue
7478
if v["was_translated"] is True:
7579
new_input[v["translated_key"]] = v["translated_value"]
7680
print("Reformatted forward_mapping", new_input)

uparma/uparma.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ def translate(self, param_dict, original_style=None, translated_style=None):
233233
}
234234
}
235235
236+
In cases where e.g. only a flag is set, the translated key will be None.
236237
"""
237-
cannot_be_translated = "{0} for {1} cannot be translated into {2}"
238238
translated_params = UParmaDict()
239239

240240
for original_key, original_value in param_dict.items():
@@ -321,7 +321,8 @@ def translate(self, param_dict, original_style=None, translated_style=None):
321321
if _uparma_v == _uparma_vt:
322322
translated_value = _transtyle_v
323323
was_translated = True
324-
324+
if translated_key.endswith("<DROP_KEY>"):
325+
translated_key = None
325326
template_dict.update(
326327
{
327328
"translated_key": translated_key,

0 commit comments

Comments
 (0)