Skip to content

Commit

Permalink
Merge pull request #48 from uparma/feature/drop_non_keys
Browse files Browse the repository at this point in the history
keys without translations are set to None
  • Loading branch information
ArtiVlasov authored Mar 13, 2023
2 parents 66aafc5 + c6ef83b commit c56d1f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/test_back_and_forward_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def test_simple_back_and_forward_mapping(test_id):
for k, v in forward_mapping.items():
if isinstance(v["translated_key"], list):
continue
if v["original_key"].endswith("<DROP_KEY>"):
continue
if v["translated_key"] is None:
continue
if v["was_translated"] is True:
new_input[v["translated_key"]] = v["translated_value"]
print("Reformatted forward_mapping", new_input)
Expand Down
5 changes: 3 additions & 2 deletions uparma/uparma.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def translate(self, param_dict, original_style=None, translated_style=None):
}
}
In cases where e.g. only a flag is set, the translated key will be None.
"""
cannot_be_translated = "{0} for {1} cannot be translated into {2}"
translated_params = UParmaDict()

for original_key, original_value in param_dict.items():
Expand Down Expand Up @@ -321,7 +321,8 @@ def translate(self, param_dict, original_style=None, translated_style=None):
if _uparma_v == _uparma_vt:
translated_value = _transtyle_v
was_translated = True

if translated_key.endswith("<DROP_KEY>"):
translated_key = None
template_dict.update(
{
"translated_key": translated_key,
Expand Down

0 comments on commit c56d1f2

Please sign in to comment.