[12] allow template operations

pull/1261/head
meisnate12 2 years ago
parent 0afb243335
commit 2311ebd3f9

@ -1 +1 @@
1.18.2-develop11
1.18.2-develop12

@ -474,8 +474,16 @@ class DataFile:
return og_txt
elif str(og_txt) == f"<<{var}>>":
return actual_value
elif f"<<{var}>>" in str(og_txt):
return str(og_txt).replace(f"<<{var}>>", str(actual_value))
elif f"<<{var}" in str(og_txt):
final = str(og_txt).replace(f"<<{var}>>", str(actual_value)) if f"<<{var}>>" in str(og_txt) else str(og_txt)
if f"<<{var}" in final:
match = re.search(f"<<({var}([+-])(\d+))>>", final)
if match:
try:
final = final.replace(f"<<{match.group(1)}>>", str(int(actual_value) + (int(match.group(3)) * (-1 if match.group(2) == "-" else 1))))
except ValueError:
raise Failed(f"Template Error: {actual_value} must be a number to use {match.group(1)}")
return final
else:
return og_txt
if _debug:

Loading…
Cancel
Save