[12] allow template operations

This commit is contained in:
meisnate12 2023-01-09 17:01:02 -05:00
parent 0afb243335
commit 2311ebd3f9
2 changed files with 11 additions and 3 deletions

View file

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

View file

@ -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: