diff --git a/src/tirith/core/policy_parameterization.py b/src/tirith/core/policy_parameterization.py index 022251e..df0e52b 100644 --- a/src/tirith/core/policy_parameterization.py +++ b/src/tirith/core/policy_parameterization.py @@ -1,9 +1,11 @@ import re import pydash + class PydashPathNotFound: pass + def check_match(string: str, pattern: re.Pattern) -> re.Match: match_ = re.fullmatch(pattern, string) return match_ @@ -14,7 +16,7 @@ def helper(dictionary: dict, var_pattern: re.Pattern, var_dict: dict): if isinstance(value, str): match = check_match(value, var_pattern) if bool(match): - dictionary[key] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound) + dictionary[key] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound) def replace_vars(policy_dict: dict, var_dict: dict) -> dict: @@ -25,13 +27,13 @@ def replace_vars(policy_dict: dict, var_dict: dict) -> dict: for i in range(len(evaluators)): match = check_match(evaluators[i]["id"], var_pattern) if bool(match): - evaluators[i]["id"] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound) + evaluators[i]["id"] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound) helper(evaluators[i]["condition"], var_pattern, var_dict) helper(evaluators[i]["provider_args"], var_pattern, var_dict) match = check_match(policy_dict["eval_expression"], var_pattern) if bool(match): - policy_dict["eval_expression"] = pydash.get(var_dict, match.group(1),default=PydashPathNotFound) + policy_dict["eval_expression"] = pydash.get(var_dict, match.group(1), default=PydashPathNotFound) - return policy_dict \ No newline at end of file + return policy_dict diff --git a/tests/core/test_policy_parameterization.py b/tests/core/test_policy_parameterization.py index 2ba1af7..02ad907 100644 --- a/tests/core/test_policy_parameterization.py +++ b/tests/core/test_policy_parameterization.py @@ -2,6 +2,7 @@ from tirith.core.policy_parameterization import replace_vars, PydashPathNotFound + @pytest.fixture def processed_policy(): var_dict = {