diff --git a/scripts/export.py b/scripts/export.py index 0779fba7a..d0b6cd737 100644 --- a/scripts/export.py +++ b/scripts/export.py @@ -100,7 +100,9 @@ def load_rules(): """ def load_controls(loaded_rules: dict): - with open(os.path.join(__CWD__, 'categories', 'mapCategoryNameToID.json'), "r") as f: + map_category_name_to_id_file = 'mapCategoryNameToID.json' + + with open(os.path.join(__CWD__, 'categories', map_category_name_to_id_file), "r") as f: map_category_name_to_id = json.load(f) p2 = os.path.join(__CWD__, 'controls') @@ -134,14 +136,14 @@ def load_controls(loaded_rules: dict): if category_name in map_category_name_to_id: new_control[category_field_name][id_field] = map_category_name_to_id[category_name] else: - raise TypeError(f"Failed to find category name '{category_name}' in mapCategoryNameToID.json") + raise TypeError(f"Failed to find category name '{category_name}' in {map_category_name_to_id_file}") if sub_category_field_name in new_control[category_field_name]: sub_category_name = new_control[category_field_name][sub_category_field_name][name_field] if sub_category_name in map_category_name_to_id: new_control[category_field_name][sub_category_field_name][id_field] = map_category_name_to_id[sub_category_name] else: - raise TypeError(f"Failed to find subcategory name '{sub_category_name}' in mapCategoryNameToID.json") + raise TypeError(f"Failed to find subcategory name '{sub_category_name}' in {map_category_name_to_id_file}") new_control["rules"] = [] new_control_copy = copy.deepcopy(new_control)