add mapping_sort variable, like collection_sort

Simply doing the same thing with `move_prefix`, but on the mapping name.
This commit is contained in:
Yossef Mendelssohn 2024-03-20 15:29:52 -04:00
parent 56961ccca1
commit 68a7aa616d

View file

@ -436,6 +436,7 @@ class DataFile:
optional.append(f"{final_key}_encoded") optional.append(f"{final_key}_encoded")
sort_name = None sort_name = None
sort_mapping = None
if "move_prefix" in template or "move_collection_prefix" in template: if "move_prefix" in template or "move_collection_prefix" in template:
prefix = None prefix = None
if "move_prefix" in template: if "move_prefix" in template:
@ -448,10 +449,13 @@ class DataFile:
for op in util.get_list(prefix): for op in util.get_list(prefix):
if variables[name_var].startswith(f"{op} "): if variables[name_var].startswith(f"{op} "):
sort_name = f"{variables[name_var][len(op):].strip()}, {op}" sort_name = f"{variables[name_var][len(op):].strip()}, {op}"
break if variables["mapping_name"].startswith(f"{op} "):
sort_mapping = f"{variables['mapping_name'][len(op):].strip()}, {op}"
break if sort_name and sort_mapping
else: else:
raise Failed(f"{self.data_type} Error: template sub-attribute move_prefix is blank") raise Failed(f"{self.data_type} Error: template sub-attribute move_prefix is blank")
variables[f"{self.data_type.lower()}_sort"] = sort_name if sort_name else variables[name_var] variables[f"{self.data_type.lower()}_sort"] = sort_name if sort_name else variables[name_var]
variables["mapping_sort"] = sort_mapping if sort_mapping else variables["mapping_name"]
for key, value in variables.copy().items(): for key, value in variables.copy().items():
if "<<" in key and ">>" in key: if "<<" in key and ">>" in key: