diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2022-03-21 17:17:52 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2022-03-21 17:17:52 +0100 |
commit | 2592ddc7f3c5d8ef073e984a51e7887c5238c111 (patch) | |
tree | 441935c3db9b4d4f45bb8408b395bbec705f0577 /bin | |
parent | a99c547b270410634a483c87a8197cd65066c346 (diff) |
observations-enum-to-bool: warn if a key is not unique
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/observations-enum-to-boolean.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/observations-enum-to-boolean.py b/bin/observations-enum-to-boolean.py index 3d014ea..20cff32 100755 --- a/bin/observations-enum-to-boolean.py +++ b/bin/observations-enum-to-boolean.py @@ -30,10 +30,14 @@ def main(): replace_map[param_name] = distinct_values for observation in observations: + binary_keys = set() for k, v in replace_map.items(): enum_value = observation["param"].pop(k) for binary_key in v: observation["param"][binary_key] = int(enum_value == binary_key) + if binary_key in binary_keys: + print(f"Error: key '{binary_key}' is not unique") + binary_keys.add(binary_key) with lzma.open(outfile, "wt") as f: json.dump(observations, f) |