changes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -55,6 +55,37 @@ def resolve_value(expr, context):
|
|||||||
print(f" [ERROR] Math function {func_name} failed with values: {arg1_val}, {arg2_val}")
|
print(f" [ERROR] Math function {func_name} failed with values: {arg1_val}, {arg2_val}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
# 2.1. Hàm xử lý list: $append(list, element)
|
||||||
|
# =============================================
|
||||||
|
append_match = re.match(r"^\$append\(([^,]+),\s*(.+)\)$", expr, re.DOTALL)
|
||||||
|
if append_match:
|
||||||
|
list_expr = append_match.group(1).strip()
|
||||||
|
element_expr = append_match.group(2).strip()
|
||||||
|
|
||||||
|
# 1. Resolve the list
|
||||||
|
target_list = resolve_value(list_expr, context)
|
||||||
|
if target_list is None:
|
||||||
|
target_list = []
|
||||||
|
|
||||||
|
# Ensure it's a copy so we don't modify the original context variable directly
|
||||||
|
target_list = list(target_list)
|
||||||
|
|
||||||
|
# 2. Resolve the element
|
||||||
|
resolved_element = resolve_value(element_expr, context)
|
||||||
|
|
||||||
|
if isinstance(resolved_element, str):
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
element_to_append = json.loads(resolved_element)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
element_to_append = resolved_element
|
||||||
|
else:
|
||||||
|
element_to_append = resolved_element
|
||||||
|
|
||||||
|
target_list.append(element_to_append)
|
||||||
|
return target_list
|
||||||
|
|
||||||
# =============================================
|
# =============================================
|
||||||
# 3. Helper: Lấy giá trị từ context theo đường dẫn dotted
|
# 3. Helper: Lấy giá trị từ context theo đường dẫn dotted
|
||||||
# =============================================
|
# =============================================
|
||||||
|
|||||||
Reference in New Issue
Block a user