feat(854-2): M01 [로직 복사/생성] 이 수식 문서를 같이 지음 · 로직 지우면 문서도 — 묶음 ③
- Doc.make = 빌더와 같은 변환(convert) · 같은 대조(옛 엔진 = 새 계산기 · 기본 + 옵션 표본 · 부르는 단가산출 저장본)를 지난 것만 수식_<파일>.json 에 씀(빌더가 다시 지어도 같은 글) · 못 지나면 안 씀 - Store_Make.logic_new(/logic/copy · /logic/formula/save 공용)가 make 부름 · 답에 「수식문서」 - Store_Make.save 의 로직 줄 지움(/save)도 그 수식 문서를 지움(/logic/remove 와 같은 끝 · 문서만 남지 않게) - 빌더 build_수식문서_802_2 = 대조 갈래 cases_of · agree 로 꺼냄(동작 같음 · --check 같음) - 시험 test_854_2_m01_copy_doc — 복사 · 식 복사 → 문서 있음 · 금액 = 옛 엔진 = 본뜬 로직 · 빌더 다시 지음 = 같은 파일 글 · 지움 → 문서 없음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,23 @@ def new_answer(links, doc: dict, given: dict | None = None):
|
||||
return {"결과": got["결과"]} if doc.get("결과") else {k: got.get(k) for k in KEYS}
|
||||
|
||||
|
||||
def cases_of(whole, row: dict) -> list[tuple]:
|
||||
"""(옵션 글, 옛 엔진 입력, 새 문서에 넘길 바뀐 입력) — 기본 + 고르기 입력의 다른 갈래 하나씩."""
|
||||
base = meq.given_of(whole, row)
|
||||
cases = [("", base, None)]
|
||||
for spec in row.get("입력") or []:
|
||||
for opt in spec.get("고르기") or []:
|
||||
if str(opt) != str(base.get(spec["이름"])):
|
||||
one = {spec["이름"]: opt}
|
||||
cases.append((f"{spec['이름']}={opt}", {**base, **one}, one))
|
||||
return cases
|
||||
|
||||
|
||||
def agree(old, new) -> bool:
|
||||
"""대조 같음 — 같은 값 · 둘 다 못 셈."""
|
||||
return old == new or (isinstance(old, str) and isinstance(new, str))
|
||||
|
||||
|
||||
def _text(v) -> str:
|
||||
if isinstance(v, str):
|
||||
return v
|
||||
@@ -137,17 +154,11 @@ def build(log=print) -> dict:
|
||||
links = ml.Links(whole, docs)
|
||||
runs, both_out = [], 0
|
||||
for _, row in items:
|
||||
key, base = str(row["키"]), meq.given_of(whole, row)
|
||||
cases = [("", base, None)] # (옵션 글, 옛 엔진 입력, 새 문서에 넘길 바뀐 입력)
|
||||
for spec in row.get("입력") or []:
|
||||
for opt in spec.get("고르기") or []:
|
||||
if str(opt) != str(base.get(spec["이름"])):
|
||||
one = {spec["이름"]: opt}
|
||||
cases.append((f"{spec['이름']}={opt}", {**base, **one}, one))
|
||||
for label, given, changed in cases:
|
||||
key = str(row["키"])
|
||||
for label, given, changed in cases_of(whole, row):
|
||||
old = old_answer(whole, row, given)
|
||||
new = new_answer(links, docs[key], changed)
|
||||
same = old == new or (isinstance(old, str) and isinstance(new, str))
|
||||
same = agree(old, new)
|
||||
both_out += isinstance(old, str) and isinstance(new, str)
|
||||
runs.append(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user