diff --git a/VERSION b/VERSION index 7abf0605..a9d46403 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.1-develop10 +1.17.1-develop11 diff --git a/modules/meta.py b/modules/meta.py index e01186ac..b79133e8 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -156,7 +156,15 @@ class DataFile: for key, value in variables.copy().items(): variables[f"{key}_encoded"] = requests.utils.quote(str(value)) + conditional = {} default = {} + def add_default(d_key, d_value): + for v_key, v_value in variables.items(): + if f"<<{v_key}>>" in str(d_value): + d_value = str(d_value).replace(f"<<{v_key}>>", str(v_value)) + default[d_key] = d_value + default[f"{d_key}_encoded"] = requests.utils.quote(str(d_value)) + if "default" in template: if not template["default"]: raise Failed(f"{self.data_type} Error: template sub-attribute default is blank") @@ -169,11 +177,25 @@ class DataFile: final_key = final_key.replace(f"<<{k}>>", str(v)) if final_key not in optional: final_value = template["default"][dv] - for key, value in variables.items(): - if f"<<{key}>>" in str(final_value): - final_value = str(final_value).replace(f"<<{key}>>", str(value)) - default[final_key] = final_value - default[f"{final_key}_encoded"] = requests.utils.quote(str(final_value)) + if isinstance(final_value, dict): + if "variable" not in final_value: + raise Failed(f"{self.data_type} Error: variable sub-attribute required when the default variable is a dictionary") + if "default" not in final_value: + raise Failed(f"{self.data_type} Error: default sub-attribute required when the default variable is a dictionary") + if "values" not in final_value: + raise Failed(f"{self.data_type} Error: values sub-attribute required when the default variable is a dictionary") + conditional[final_key] = final_value + else: + add_default(final_key, final_value) + + for con, con_data in conditional.items(): + final_value = con_data["default"] + if con_data["variable"] in variables: + if variables[con_data["variable"]] in con_data["values"]: + final_value = con_data["values"][variables[con_data["variable"]]] + elif con_data["variable"] in default and default[con_data["variable"]] in con_data["values"]: + final_value = con_data["values"][variables[con_data["variable"]]] + add_default(con, final_value) if "optional" in template: if template["optional"]: diff --git a/modules/operations.py b/modules/operations.py index f778f6b3..8a16a5a7 100644 --- a/modules/operations.py +++ b/modules/operations.py @@ -392,7 +392,7 @@ class Operations: except Failed: pass - item.saveEdits() + ep.saveEdits() if len(batch_display) > 0: logger.info(f"Batch Edits{batch_display}")