Strategy change new rule (Part2 - Fix)
This commit is contained in:
Binary file not shown.
@@ -766,7 +766,7 @@ def _execute_custom_function(function_name, args, output_inclusion):
|
|||||||
elif function_name == "if_then_else":
|
elif function_name == "if_then_else":
|
||||||
# Unified conditional function
|
# Unified conditional function
|
||||||
# Syntax: ["operator", arg1, arg2_optional, result_if_true, result_if_false]
|
# Syntax: ["operator", arg1, arg2_optional, result_if_true, result_if_false]
|
||||||
# Operators: "is_true", "is_false", "all_true", "any_true", "is_defined", "is_undefined", "all_defined", "==", "!="
|
# Operators: "is_true", "is_false", "all_true", "any_true", "is_defined", "is_undefined", "all_defined", "==", "!=", ">", ">=", "<", "<="
|
||||||
# Sentinel propagation: "undefined" (inconnu) > "N/A" (non applicable) > vraie valeur.
|
# Sentinel propagation: "undefined" (inconnu) > "N/A" (non applicable) > vraie valeur.
|
||||||
|
|
||||||
if not args or len(args) < 4:
|
if not args or len(args) < 4:
|
||||||
@@ -935,6 +935,47 @@ def _execute_custom_function(function_name, args, output_inclusion):
|
|||||||
result_if_true = resolve_value(args[3])
|
result_if_true = resolve_value(args[3])
|
||||||
result_if_false = resolve_value(args[4])
|
result_if_false = resolve_value(args[4])
|
||||||
|
|
||||||
|
elif operator in (">", ">=", "<", "<="):
|
||||||
|
if len(args) != 5:
|
||||||
|
return f"$$$$ Argument Error: {operator} requires 5 arguments"
|
||||||
|
value1 = resolve_value(args[1])
|
||||||
|
value2 = resolve_value(args[2])
|
||||||
|
|
||||||
|
v1_undef = value1 is None or value1 == "undefined"
|
||||||
|
v2_undef = value2 is None or value2 == "undefined"
|
||||||
|
status = dominant_no_value(v1_undef or v2_undef,
|
||||||
|
value1 == "N/A" or value2 == "N/A")
|
||||||
|
if status:
|
||||||
|
return status
|
||||||
|
|
||||||
|
# Si l'un est numérique, tenter de convertir l'autre ; sinon comparer en string
|
||||||
|
cmp1, cmp2 = value1, value2
|
||||||
|
if isinstance(value1, (int, float)) and not isinstance(value2, (int, float)):
|
||||||
|
try:
|
||||||
|
cmp2 = float(value2)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
cmp1 = str(value1)
|
||||||
|
elif isinstance(value2, (int, float)) and not isinstance(value1, (int, float)):
|
||||||
|
try:
|
||||||
|
cmp1 = float(value1)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
cmp2 = str(value2)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if operator == ">":
|
||||||
|
condition = (cmp1 > cmp2)
|
||||||
|
elif operator == ">=":
|
||||||
|
condition = (cmp1 >= cmp2)
|
||||||
|
elif operator == "<":
|
||||||
|
condition = (cmp1 < cmp2)
|
||||||
|
else:
|
||||||
|
condition = (cmp1 <= cmp2)
|
||||||
|
except TypeError:
|
||||||
|
return f"$$$$ Comparison Error: cannot compare {type(cmp1).__name__} and {type(cmp2).__name__}"
|
||||||
|
|
||||||
|
result_if_true = resolve_value(args[3])
|
||||||
|
result_if_false = resolve_value(args[4])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return f"$$$$ Unknown Operator: {operator}"
|
return f"$$$$ Unknown Operator: {operator}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user