|
|
@ -112,7 +112,6 @@ class DataFile:
|
|
|
|
elif not template_call:
|
|
|
|
elif not template_call:
|
|
|
|
raise Failed(f"{self.data_type} Error: template attribute is blank")
|
|
|
|
raise Failed(f"{self.data_type} Error: template attribute is blank")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.debug(f"Value: {template_call}")
|
|
|
|
|
|
|
|
new_attributes = {}
|
|
|
|
new_attributes = {}
|
|
|
|
for variables in util.get_list(template_call, split=False):
|
|
|
|
for variables in util.get_list(template_call, split=False):
|
|
|
|
if not isinstance(variables, dict):
|
|
|
|
if not isinstance(variables, dict):
|
|
|
@ -126,6 +125,9 @@ class DataFile:
|
|
|
|
elif not isinstance(self.templates[variables["name"]][0], dict):
|
|
|
|
elif not isinstance(self.templates[variables["name"]][0], dict):
|
|
|
|
raise Failed(f"{self.data_type} Error: template {variables['name']} is not a dictionary")
|
|
|
|
raise Failed(f"{self.data_type} Error: template {variables['name']} is not a dictionary")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Template {variables['name']}")
|
|
|
|
|
|
|
|
logger.debug(f"Call: {variables}")
|
|
|
|
|
|
|
|
|
|
|
|
remove_variables = []
|
|
|
|
remove_variables = []
|
|
|
|
for tm in variables:
|
|
|
|
for tm in variables:
|
|
|
|
if variables[tm] is None:
|
|
|
|
if variables[tm] is None:
|
|
|
@ -204,7 +206,8 @@ class DataFile:
|
|
|
|
optional.append(str(op))
|
|
|
|
optional.append(str(op))
|
|
|
|
optional.append(f"{op}_encoded")
|
|
|
|
optional.append(f"{op}_encoded")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.warning(f"Template Warning: variable {op} cannot be optional if it has a default")
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug(f"Template Warning: variable {op} cannot be optional if it has a default")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise Failed(f"{self.data_type} Error: template sub-attribute optional is blank")
|
|
|
|
raise Failed(f"{self.data_type} Error: template sub-attribute optional is blank")
|
|
|
|
|
|
|
|
|
|
|
@ -231,13 +234,13 @@ class DataFile:
|
|
|
|
if not isinstance(conditions, list):
|
|
|
|
if not isinstance(conditions, list):
|
|
|
|
raise Failed(f"{self.data_type} Error: conditions sub-attribute must be a list or dictionary")
|
|
|
|
raise Failed(f"{self.data_type} Error: conditions sub-attribute must be a list or dictionary")
|
|
|
|
condition_found = False
|
|
|
|
condition_found = False
|
|
|
|
for condition in conditions:
|
|
|
|
for i, condition in enumerate(conditions, 1):
|
|
|
|
if not isinstance(condition, dict):
|
|
|
|
if not isinstance(condition, dict):
|
|
|
|
raise Failed(f"{self.data_type} Error: each condition must be a dictionary")
|
|
|
|
raise Failed(f"{self.data_type} Error: each condition must be a dictionary")
|
|
|
|
if "value" not in condition:
|
|
|
|
if "value" not in condition:
|
|
|
|
raise Failed(f"{self.data_type} Error: each condition must have a result value")
|
|
|
|
raise Failed(f"{self.data_type} Error: each condition must have a result value")
|
|
|
|
condition_passed = True
|
|
|
|
condition_passed = True
|
|
|
|
for i, (var_key, var_value) in enumerate(condition.items(), 1):
|
|
|
|
for var_key, var_value in condition.items():
|
|
|
|
if var_key == "value":
|
|
|
|
if var_key == "value":
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
var_key = small_var_check(var_key)
|
|
|
|
var_key = small_var_check(var_key)
|
|
|
@ -245,13 +248,19 @@ class DataFile:
|
|
|
|
if var_key in variables:
|
|
|
|
if var_key in variables:
|
|
|
|
if (isinstance(var_value, list) and variables[var_key] not in var_value) or \
|
|
|
|
if (isinstance(var_value, list) and variables[var_key] not in var_value) or \
|
|
|
|
(not isinstance(var_value, list) and variables[var_key] != var_value):
|
|
|
|
(not isinstance(var_value, list) and variables[var_key] != var_value):
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" {"not in" if isinstance(var_value, list) else "is not"} {var_value}')
|
|
|
|
if isinstance(var_value, list):
|
|
|
|
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" not in {var_value}')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" is not "{var_value}"')
|
|
|
|
condition_passed = False
|
|
|
|
condition_passed = False
|
|
|
|
break
|
|
|
|
break
|
|
|
|
elif var_key in default:
|
|
|
|
elif var_key in default:
|
|
|
|
if (isinstance(var_value, list) and default[var_key] not in var_value) or \
|
|
|
|
if (isinstance(var_value, list) and default[var_key] not in var_value) or \
|
|
|
|
(not isinstance(var_value, list) and default[var_key] != var_value):
|
|
|
|
(not isinstance(var_value, list) and default[var_key] != var_value):
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" {"not in" if isinstance(var_value, list) else "is not"} {var_value}')
|
|
|
|
if isinstance(var_value, list):
|
|
|
|
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" not in {var_value}')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" is not "{var_value}"')
|
|
|
|
condition_passed = False
|
|
|
|
condition_passed = False
|
|
|
|
break
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -280,7 +289,8 @@ class DataFile:
|
|
|
|
if "move_prefix" in template:
|
|
|
|
if "move_prefix" in template:
|
|
|
|
prefix = template["move_prefix"]
|
|
|
|
prefix = template["move_prefix"]
|
|
|
|
elif "move_collection_prefix" in template:
|
|
|
|
elif "move_collection_prefix" in template:
|
|
|
|
logger.warning(f"{self.data_type} Error: template sub-attribute move_collection_prefix will run as move_prefix")
|
|
|
|
logger.debuf("")
|
|
|
|
|
|
|
|
logger.debug(f"{self.data_type} Warning: template sub-attribute move_collection_prefix will run as move_prefix")
|
|
|
|
prefix = template["move_collection_prefix"]
|
|
|
|
prefix = template["move_collection_prefix"]
|
|
|
|
if prefix:
|
|
|
|
if prefix:
|
|
|
|
for op in util.get_list(prefix):
|
|
|
|
for op in util.get_list(prefix):
|
|
|
@ -297,7 +307,6 @@ class DataFile:
|
|
|
|
logger.debug(f"Defaults: {default}")
|
|
|
|
logger.debug(f"Defaults: {default}")
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug(f"Optional: {optional}")
|
|
|
|
logger.debug(f"Optional: {optional}")
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_for_var(_method, _data):
|
|
|
|
def check_for_var(_method, _data):
|
|
|
|
def scan_text(og_txt, var, actual_value):
|
|
|
|
def scan_text(og_txt, var, actual_value):
|
|
|
@ -352,11 +361,13 @@ class DataFile:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
new_name = check_for_var(method_name, method_name)
|
|
|
|
new_name = check_for_var(method_name, method_name)
|
|
|
|
if new_name in new_attributes:
|
|
|
|
if new_name in new_attributes:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
logger.warning(f"Template Warning: template attribute: {new_name} from {variables['name']} skipped")
|
|
|
|
logger.warning(f"Template Warning: template attribute: {new_name} from {variables['name']} skipped")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
new_attributes[new_name] = check_data(new_name, attr_data)
|
|
|
|
new_attributes[new_name] = check_data(new_name, attr_data)
|
|
|
|
except Failed:
|
|
|
|
except Failed:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug(f"Final Template Attributes: {new_attributes}")
|
|
|
|
logger.debug(f"Final Template Attributes: {new_attributes}")
|
|
|
|
logger.debug("")
|
|
|
|
logger.debug("")
|
|
|
|
return new_attributes
|
|
|
|
return new_attributes
|
|
|
|