From 1ce88964769b18bcbc8d851979ee095c80966a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C5=A0incek?= <35937483+ivan-sincek@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:38:39 +0200 Subject: [PATCH] Template Parsing Bug Fix --- src/chad_extractor/chad_extractor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chad_extractor/chad_extractor.py b/src/chad_extractor/chad_extractor.py index a44177e..40748b6 100644 --- a/src/chad_extractor/chad_extractor.py +++ b/src/chad_extractor/chad_extractor.py @@ -278,7 +278,7 @@ def get_results(self): # 1st round: extraction - pop all entries with no "extract" RegEx # 2nd round: validation - pop all entries with no "validate" RegEx def parse_template(self): - for key in self.__template: + for key in list(self.__template.keys()): if self.__active["regex"] not in self.__template[key]: self.__template.pop(key) return bool(self.__template) @@ -894,6 +894,9 @@ def __validate_template_keys(self, value): elif len(pvalue) < 1: self.__error("Template: All primary keys must have at least one sub-key") break + elif KEYS["extract"]["regex"] not in pvalue: + self.__error(f"Template[{pkey}]: Must contain '{KEYS['extract']['regex']}' sub-key") + break error = False for skey, svalue in pvalue.items(): if skey in [KEYS["extract"]["regex"], KEYS["validate"]["regex"]]: