From 2592ddc7f3c5d8ef073e984a51e7887c5238c111 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 21 Mar 2022 17:17:52 +0100 Subject: observations-enum-to-bool: warn if a key is not unique --- bin/observations-enum-to-boolean.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bin') 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) -- cgit v1.2.3