Skip to content

Commit

Permalink
use const
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Grunberger committed Jul 24, 2023
1 parent 30cd434 commit 163298d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 163298d

Please sign in to comment.