Files
Aislo/M02_MasterTemplete/M02_Sangeun_Block.py
T
eomsangdonandClaude Opus 5.5 47b2268939 chore(853-2): 걸음 0 묶음 ③ — 부르는 곳 0 · 시험만 부르는 함수 걷음
- 서버: Elem_Alias.region_of · MyMachine.logic_for · Sangeun_Const.drop_add_keys · Sangeun_QtyLinks._hangul · Book.migrate_paths · Sangeun_Block.names
- 화면: laborGrid(+ 딸린 gridOf) · mountDrawingView · DRAWING_HELP · checkDraft(+ DraftCheck) · suggestPlaces · withFirst · putDraft · newTag · crewSummary · machineHourly(+ MachineHourly) · coverCalls · qtyText
- 시험: migrate_paths 만 보던 tree 한 함수 지움 · 거울 시험에서 걷은 TS 몫만 뺌(821-2 시간당 · 846-1 부름 · labor_values qtyText)
- 남김: Combo_Store listing · create · edit · delete — 시험 28 개가 조합 만들기 바탕으로 씀 · 지우면 M01 Store_Combo 만들기 길도 죽음(sub1 몫) · 브레인 판단
- 검증: 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 536 통과 · typecheck 0 · 서버 로그 오류 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:09:31 +09:00

89 lines
4.4 KiB
Python

"""M02 단가산출(SK) 더한 기초 블록 [연결 끊기] · [다시 잇기](PLAN 796-2e · 요구 659-3 · 656-1).
더한 기초 = 더한줄 로직(`종류: 로직`). 기본 = 연결 — 이 SK 의 로직 사본(`M02_Sangeun_Copy`)이 닿는 그 기초
(원본 바뀜은 [재생성]·[다시 잇기]에서 따라옴 · 자동 아님 · 보기만).
끊음 = 더한줄 칸 `끊음` {시점, 로직 [M01 줄]} — 끊는 때 그 기초가 닿는 닫힌 묶음(하위 로직 · 찾기 표 ·
요율 · 사본 줄 그대로 = 금액 그대로)을 이 SK 안 자기 사본으로 굳힘 → 그 줄만 고침:
칸 `수식고침`(796-2b 와 같은 꼴 · 같은 `eqm.apply`)을 그 기초 줄에 얹어 셈(`Calc.sub_run`).
[재생성] = 끊은 기초의 줄은 안 바꿈(자원 단가만 — 단가는 SK 사본 `단가` · [단가 갱신] 한 길).
다시 잇기 = `끊음` · `수식고침` 뗌 + 표지 `다시잇기`(서버만 · 셈·저장 첫머리 `Copy.settle` 이 그 기초가 닿는
닫힌 묶음을 지금 M01 줄로 갈음하고 표지 뗌 — 고친 것 버림).
화면 길(끊기 · 다시 잇기 · 끊은 기초 수식 탭)은 걷음(894) — 남은 것 = 저장 문서의 `끊음` · `수식고침` 꼴 · 셈.
저장 = SK [저장](서버가 다시 얹어 검사 · 셈 · 브라우저 값 안 받음 — 끊음 줄은 사본과 같은 `taken` 꼴 검사).
"""
from __future__ import annotations
from typing import Any
from M02_MasterTemplete import M02_Sangeun_Copy as skc
from M02_MasterTemplete import M02_Sangeun_Doc as sd
from M02_MasterTemplete import M02_Sangeun_Equation as eqm
CUT, EDIT = "끊음", eqm.KEY
MANY = 400 # 끊은 기초가 닿는 줄 상한
_OWN: dict[int, tuple[Any, Any, Any]] = {}
def is_block(one: Any) -> bool:
"""더한 기초 = 더한줄 로직(참조 · 고정 · 자원 줄 아님)."""
return isinstance(one, dict) and one.get("종류") == "로직" and bool(one.get("로직"))
def clean(raw: dict, where: str) -> dict:
"""`sd._added` 가 부름 — 끊음 · 수식고침 꼴만(뜻 검사는 셈 · 저장 `strict`)."""
cut = raw.get(CUT)
if not cut:
if raw.get(EDIT):
raise sd.DocError(f"{where} · 수식 고침은 연결을 끊은 기초만")
return {}
rows = cut.get("로직") if isinstance(cut, dict) else None
code = str(raw.get("로직"))
if any(raw.get(k) not in (None, {}, []) for k in sd.BODY):
raise sd.DocError(f"{where} · 넣은 SK 몸은 이미 이 SK 안 사본 — 연결 끊기 없음")
if (
not isinstance(rows, list)
or len(rows) > MANY
or not all(isinstance(r, dict) and r.get("키") for r in rows)
):
raise sd.DocError(f"{where} · 끊은 기초 사본 꼴이 틀림")
rows = [r for r in rows if str(r["키"])[:2] not in skc.RES] # 단가 = SK 사본 한 곳
if code not in {str(r["키"]) for r in rows}:
raise sd.DocError(f"{where} · 끊은 기초 사본에 「{code}」 줄 없음")
return {CUT: {"시점": str(cut.get("시점") or ""), "로직": rows}} | eqm.clean(raw, {})
def own(one: dict, whole: Any) -> Any:
"""끊은 기초의 셈 색인 — `whole` 위에 자기 사본 줄(끊음 아님 = `whole` 그대로)."""
cut = one.get(CUT)
if not isinstance(cut, dict):
return whole
hit = _OWN.get(id(cut))
if hit and hit[0] is cut and hit[1] is whole:
return hit[2]
if len(_OWN) > 32: # ponytail: 통째 비움 · 끊은 기초가 많아 느려지면 LRU 로
_OWN.clear()
got = skc.Copy(whole, skc._rows(cut))
_OWN[id(cut)] = (cut, whole, got)
return got
def row_of(whole: Any, one: dict, edits: list | None = None) -> tuple[dict, list[str], Any]:
"""(끊은 기초 줄 + 수식 고침, 못 얹은 까닭, 그 기초 셈 색인) — `edits` None = 그 기초 자기 고침."""
mine = own(one, whole)
row = mine.logic(str(one["로직"]))
use = one.get(EDIT) if edits is None else edits
if not use:
return row, [], mine
new, why = eqm.apply(row, use, mine)
return new, why, mine
def strict(doc: dict, whole: Any) -> None:
"""저장 — 끊은 기초 고침이 못 얹히면 400."""
for at, one in enumerate(doc.get("더한줄") or [], 1):
if is_block(one) and one.get(EDIT):
why = row_of(whole, one)[1]
if why:
raise sd.DocError(f"더한줄 {at}째 수식 고침 못 얹음 — " + " · ".join(why))