mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 07:23:03 +08:00
feat(gui): 编排窗口支持算术表达式解析与回显
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -560,6 +560,8 @@ def encodeValueStr(
|
||||
var_type: str
|
||||
) -> str:
|
||||
|
||||
if isArithExpr(raw_value):
|
||||
return raw_value
|
||||
if var_type == "Time":
|
||||
if raw_value.startswith("+") or raw_value.startswith("-"):
|
||||
return raw_value
|
||||
@@ -609,6 +611,20 @@ def stripOuterParens(
|
||||
return s
|
||||
|
||||
|
||||
# Pre-compiled pattern for detecting arithmetic expressions like "A + B" / "C - D"
|
||||
_RE_ARITH_EXPR = re.compile(r'^.+?\s+[+-]\s+.+$')
|
||||
|
||||
|
||||
def isArithExpr(
|
||||
expr: str
|
||||
) -> bool:
|
||||
"""
|
||||
Return True if expr looks like a two-operand arithmetic expression (A ± B).
|
||||
"""
|
||||
|
||||
return bool(_RE_ARITH_EXPR.match(expr.strip()))
|
||||
|
||||
|
||||
def isVarReference(
|
||||
expr: str
|
||||
) -> bool:
|
||||
@@ -623,6 +639,8 @@ def isVarReference(
|
||||
return False
|
||||
if re.match(r"^[+-]?\d", s):
|
||||
return False
|
||||
if isArithExpr(s):
|
||||
return False
|
||||
return bool(re.match(r"^[A-Z_][A-Z0-9_]*$", up))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user