summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2022-03-21 17:17:52 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2022-03-21 17:17:52 +0100
commit2592ddc7f3c5d8ef073e984a51e7887c5238c111 (patch)
tree441935c3db9b4d4f45bb8408b395bbec705f0577 /bin
parenta99c547b270410634a483c87a8197cd65066c346 (diff)
observations-enum-to-bool: warn if a key is not unique
Diffstat (limited to 'bin')
-rwxr-xr-xbin/observations-enum-to-boolean.py4
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)