Skip to content

Commit

Permalink
eval lists
Browse files Browse the repository at this point in the history
  • Loading branch information
pgierz committed Jan 23, 2025
1 parent 66e23a5 commit 7aef465
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/esm_parser/esm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,11 @@ def do_math_in_entry(tree, rhs, config):
return entry
if "${" in str(entry):
return entry
if str(entry).endswith("_keep_list"):
keep_list = True
entry = str(entry).replace("_keep_list", "")
else:
keep_list = False
entry = " " + str(entry) + " "
while "$((" in entry:
math, after_math = entry.split("))", 1)
Expand Down Expand Up @@ -2409,6 +2414,8 @@ def do_math_in_entry(tree, rhs, config):
index += 1
result = eval(math)
if isinstance(result, list):
if keep_list:
return ListWithProvenance(result, [])
result = result[
-1
] # should be extended in the future - here: if list (= if diff between dates) than result in seconds
Expand Down

0 comments on commit 7aef465

Please sign in to comment.