feat(M01): 기계 입력이 EQ 키로 와도 원문 분류번호로 풀어 받음 (PLAN 8-2)
- 고르기 목록(원문번호)과 같은 꼴로 풀어 계산 · 없는 키는 그대로 막힘 - 시험 1개 더함 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
This commit is contained in:
@@ -267,7 +267,7 @@ class Master:
|
||||
if number in slot:
|
||||
self.twice.add((key[:2], number))
|
||||
slot.setdefault(number, row)
|
||||
mp.EQ.set(self.numbers.get("EQ", {})) # 기계 입력이 목록 밖 원문 분류번호도 받게
|
||||
mp.EQ.set(self) # 기계 입력이 목록 밖 원문 분류번호도 받게
|
||||
|
||||
def get(self, ref: str) -> dict:
|
||||
tid, _, number = ref.partition(":")
|
||||
@@ -503,6 +503,7 @@ def _inputs(row: dict, given: dict) -> dict:
|
||||
pass
|
||||
if isinstance(value, (int, float)):
|
||||
value = Decimal(str(value))
|
||||
value = mp.resolve(spec, value) # 기계 EQ 키 → 원문 분류번호
|
||||
if "고르기" in spec and value not in spec["고르기"] and not mp.machine(spec, value):
|
||||
raise FormulaError(f"입력 「{name}」={value} 고르기 밖")
|
||||
if "범위" in spec:
|
||||
|
||||
@@ -27,7 +27,7 @@ REGIONS = (
|
||||
).split()
|
||||
|
||||
CHOSEN: ContextVar[dict | None] = ContextVar("고름", default=None) # {호표 줄 차례(0부터): 자재 키}
|
||||
EQ: ContextVar[dict | None] = ContextVar("기계번호", default=None) # 기계 마스터 {원문번호: 줄}
|
||||
EQ: ContextVar = ContextVar("기계번호", default=None) # 지금 쓰는 마스터 — 기계 줄을 찾음
|
||||
|
||||
|
||||
@contextmanager
|
||||
@@ -40,9 +40,22 @@ def choosing(picks: dict | None):
|
||||
CHOSEN.reset(token)
|
||||
|
||||
|
||||
def _numbers() -> dict:
|
||||
return EQ.get().numbers.get("EQ", {}) if EQ.get() else {}
|
||||
|
||||
|
||||
def resolve(spec: dict, value):
|
||||
"""기계 입력이 EQ 키로 오면 원문 분류번호로 풂 — 고르기 목록(원문번호)과 같은 꼴."""
|
||||
if not (isinstance(value, str) and value.strip()[:2] == "EQ" and EQ.get()):
|
||||
return value
|
||||
row = EQ.get().index.get("EQ", {}).get(value.strip())
|
||||
number = str(row.get("원문번호") or "") if row else ""
|
||||
return number if number and machine(spec, number) else value
|
||||
|
||||
|
||||
def machine(spec: dict, value) -> bool:
|
||||
"""기계 입력 — 고르기 목록 밖 원문 분류번호도 기계 마스터에 있으면 받음."""
|
||||
known = EQ.get() or {}
|
||||
known = _numbers()
|
||||
picks = spec.get("고르기") or []
|
||||
return bool(picks) and str(value).strip() in known and all(str(o) in known for o in picks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user