Merge remote-tracking branch 'origin/sub_laptop_4' into sub_laptop_7

This commit is contained in:
2026-11-18 08:38:45 +09:00
5 changed files with 64 additions and 35 deletions
+13 -11
View File
@@ -152,11 +152,8 @@ def line(whole: Any, doc: dict, one: dict) -> dict[str, Any]:
docs = dc.closure(whole, dc.calls(base), None) if base else {}
if base is None:
return {"기준": None, "줄": [], "재료": [], "까닭": f"수식 문서 없음 「{code}」"}
row = whole.logic(code)
mats = [] if isinstance(row.get("흐름"), dict) else row.get("호표") or []
apart = dc.apart_of(
one.get("자재표시"), [{"차례": n} for n, x in enumerate(mats) if x.get("종류") == "재료"]
)
mats = dc.prices._mat_lines(base) # 재료 금액 줄(855 L2 ⓑ-3 — 로직 줄 호표 안 읽음)
apart = dc.apart_of(one.get("자재표시"), [{"차례": n} for n, _, _ in mats])
given = dc.given_of(whole, code, one.get("입력값"))
body = dc.line_doc(base, rate, picks, apart)
ans = _traced(body, whole, docs, given, copy)
@@ -186,12 +183,12 @@ def _traced(doc: dict, whole: Any, docs: dict, given: dict, copy: dict) -> dict:
}
def _mats(items: list, ans: dict, picks: Any) -> list[dict[str, Any]]:
"""로직 자재(103-1) — 맨 위 재료 줄(호표 차례 = 문서 금액 줄 차례)마다 셈 기록이 읽은 품목 키 ·
수량 · 단가 · 금액(별도계상 · 같은 품목 400 · 호표 들이기 `_inside` 가 읽음)."""
def _mats(mats: list, ans: dict, picks: Any) -> list[dict[str, Any]]:
"""로직 자재(103-1) — 재료 금액 줄(`_mat_lines` · 단위 = 연결 단위 = 로직 원문 표기)마다
셈 기록이 읽은 품목 키 · 수량 · 단가 · 금액(별도계상 · 같은 품목 400 · `_inside` 가 읽음)."""
calls, lines, out = ans.get("부름") or [], ans.get("줄") or [], []
for n, item in enumerate(items):
if item.get("종류") != "재료" or n >= len(lines):
for n, line, link in mats:
if n >= len(lines):
continue
read = [calls[j] for j in lines[n].get("부름") or [] if j < len(calls)]
keys = [c.get("품목") for c in read] + [
@@ -200,7 +197,12 @@ def _mats(items: list, ans: dict, picks: Any) -> list[dict[str, Any]]:
key = next((k for k in keys if k), None)
head = {k: lines[n].get(k) for k in ("수량", "단가", "금액", "까닭")}
out.append(
{"차례": n, "이름": item.get("이름") or "", "단위": item.get("단위") or "", **head}
{
"차례": n,
"이름": line.get("이름") or "",
"단위": link.get("단위") or line.get("단위") or "",
}
| head
| {"품목": {"키": key} if key else None, "고름": str(n) in (picks or {})}
)
return out
+22 -11
View File
@@ -5,7 +5,7 @@
뺀줄 · 더한줄 · 수식고침 · 식 칸) = 못 셈 + 까닭 하나 · 굳힌 사본(B09 · 구조물 사본 GX9) = 옛 길(`_frozen` ·
`resolve` 바탕 사슬 · `_bundles` · `_rated` 율 더한줄 — B9 걸음 몫 · `Doc_Import._ctx` 도 고친 줄 도구를 씀).
계산 자리(CLAUDE.md 5장 ③) = 서버 단독 · 화면은 셈 길(저장 안 함 · 최신 응답만).
저장(`clean_doc`) = 꼴 검사 + 참조 위 층 · 있는 문서 · 순환 422 + 서버가 `바탕판` · `M01판` 적음.
저장(`clean_doc`) = 꼴 검사 + 참조 위 층 · 있는 문서 · 순환 422 · 바탕 머리 = 기초 문서(855 L2 ⓑ-3).
SK 단위 환산(728-2) = 배 = 바탕 기준단위(「100본」) → SK 단위(`master_unit.swap` ·
「식」 · 빈 단위 = 앞 수 뗀 바탕 단위) · 다른 성격 = 문서 `환산` {계수 | 단위중량 {종별, 형상}} ·
없으면 셈 막음(까닭) · 화면 셈 길 줄 · 계 = SK 1 단위 몫(`per_unit`).
@@ -247,9 +247,9 @@ def _bundled(item: dict, sub: dict) -> dict:
def tag_of(whole: Any, code: str) -> str:
"""꼬리표 = 기초 원문번호(「9-12-1」) · 없으면 키."""
"""꼬리표 = 기초 원문번호(「9-12-1」 · 문서 이름표 855 L2 ⓑ-3) · 없으면 키."""
try:
return str(whole.logic(code).get("원문번호") or code)
return str(sd.doc_row(whole, code).get("원문번호") or code)
except Exception: # noqa: BLE001
return code
@@ -279,10 +279,11 @@ def _bundles(row: dict, whole: Any, expand: Any, trail: tuple) -> None:
def _row_of(doc: dict, whole: Any) -> dict:
"""배 · 바탕판이 읽는 바탕 줄(셈 아님) — 바탕 로직 = 그 줄 · 없음 = 빈 줄(가져온 식 = 그 줄)."""
"""배가 읽는 바탕 머리(셈 아님) — 바탕 로직 = 기초 문서 머리(`sd.doc_row` · 855 L2 ⓑ-3) ·
없음 = 빈 줄(가져온 식 = 그 줄)."""
key = (doc.get("바탕") or {}).get("로직")
try:
return whole.logic(key) if key else sd.empty_row(doc)
return sd.doc_row(whole, key) if key else sd.empty_row(doc)
except Exception as e: # noqa: BLE001 — 없는 로직
raise sd.DocError(f"바탕 로직 · {e}") from e
@@ -311,7 +312,7 @@ def run(
copy = dsk.copy_of(doc, whole)
if copy is None:
why = dsk.OLD_WHY if dsk.own(doc) else dsk.REF_WHY
none = {"기준": None, "1단위": None, "배": Decimal(1), "바탕판": "", "줄": [], "정체": []}
none = {"기준": None, "1단위": None, "배": Decimal(1), "줄": [], "정체": []}
return {**head, **none, "까닭": why, "수식셈": {"셈됨": False, "따로": False, "까닭": why}}
row = _row_of(doc, whole)
times = ratio_of(doc, row, whole)
@@ -331,7 +332,6 @@ def run(
"기준": total,
"1단위": {k: v / times for k, v in total.items()} if total else None,
"배": times,
"바탕판": fingerprint(row),
"줄": lines,
"정체": [x["cid"] for x in lines],
"끝수": got.get("끝수"),
@@ -496,21 +496,32 @@ def _check_refs(doc: dict, here_: refs.Here) -> None:
refs._no_loop(ref, [me, ref])
def _head_of(doc: dict, whole: Any) -> dict[str, Any]:
"""저장 검사가 읽는 바탕 — 로직 바탕 · 옛 칸 고침 없음 = 기초 문서 머리(입력 이름 · 결과단위 ·
855 L2 ⓑ-3 로직 줄 안 읽음) · 그 밖(가져온 식 · 참조 · 옛 칸) = 바탕 사슬(`_base_of`)."""
if "로직" in (doc.get("바탕") or {}) and not dsk.patched(doc):
try:
return {"줄": sd.doc_row(whole, doc["바탕"]["로직"]), "짝잃음": []}
except Exception as e: # noqa: BLE001 — 엔진 FormulaError(없는 기초)
raise sd.DocError(f"바탕 로직 · {e}") from e
return _base_of(doc, whole, refs.read_ref, ())
def clean_doc(doc: Any, here_: refs.Here) -> dict[str, Any]:
"""저장 꼴(`Labor_Ref.clean_doc` 가 부름) — 검사 · 참조 · 순환 · 서버가 `바탕판` · `M01판` ·
옛 칸 덮개 · 둘째 기초 `원값` 적기는 걷음(옛 칸 셈 은퇴 · 855 2-C1)."""
"""저장 꼴(`Labor_Ref.clean_doc` 가 부름) — 검사 · 참조 · 순환 · 가져온 식 검산 · 서버가 적던
`바탕판` · `M01판` · 옛 칸 덮개 · 둘째 기초 `원값` 은 걷음(855 2-C1 · 2-D · L2 ⓑ-3)."""
raw, job = doc, doc.get(skc.JOB) if isinstance(doc, dict) else None # 수식 사본(802-4a)
whole = skc.over(doc := skc.settle(doc, True), skc.whole_()) # 사본(795-1) · 내 기계(821-1)
try:
rough = sd.clean(doc, None, whole)
_check_refs(rough, here_)
eqm.strict(base := _base_of(rough, whole, refs.read_ref, ())) # 수식 고침(796-2b)
eqm.strict(base := _head_of(rough, whole)) # 수식 고침(796-2b)
blk.strict(rough, whole) # 끊은 기초 수식 고침(796-2e)
out = sd.clean(doc, base["줄"], whole)
out["바탕"], out["더한줄"] = rough["바탕"], rough["더한줄"]
for one in out["더한줄"]: # 처음수량(744-1) = 넣을 때 수량 · 없으면 지금 수량
one.setdefault("처음수량", one["수량"])
out |= const.stamp(base["줄"], out) # 바탕판 · M01판(790-2) · 식 칸 엔진 식(792-1)
const.stamp(out) # 가져온 식 검산(793-2)
ratio_of(out, base["줄"], whole) # 단위 못 바꿈(계수 없음) = 저장 막음(728-2)
out = dsk.settle(out, whole, job, raw)
except sd.DocError as e:
+4 -8
View File
@@ -90,16 +90,12 @@ def clean_more(raw: Any, out: dict) -> dict:
return imp.clean(raw, out) # 가져온 식(793-2)
def stamp(row: dict, doc: dict | None = None) -> dict[str, Any]:
"""저장 때 서버 칸 — 바탕판(바탕 줄 지문 · 화면 「기초가 바뀜」) · 가져온 식 검산 ·
옛 `M01판`(자리마다 지문 — 읽던 시트 걷음)은 안 적음(855 2-D)."""
from M02_MasterTemplete import M02_Sangeun_Calc as calc
if doc is not None and imp.is_imported(doc): # 가져온 식 검산(793-2) = 서버가 다시
def stamp(doc: dict) -> None:
"""저장 때 서버 칸 — 가져온 식 검산(793-2 · 서버가 다시) · 옛 `바탕판`(바탕 줄 지문 · 읽는 곳 0 ·
855 L2 ⓑ-3) · 옛 `M01판`(855 2-D)은 안 적음."""
if imp.is_imported(doc):
doc[imp.KEY]["검산"] = imp.check(doc)
return {"바탕판": calc.fingerprint(row)}
# ── 고치기 ──────────────────────────────────────
def restore(doc: dict) -> dict:
+24 -4
View File
@@ -268,19 +268,39 @@ def _added_names(whole: Any, adds: Any) -> set[str]:
for one in adds or []:
if isinstance(one, dict) and one.get("종류") == "로직":
try:
out |= {
str(s.get("이름")) for s in whole.logic(str(one.get("로직"))).get("입력") or []
}
out |= {str(s.get("이름")) for s in doc_row(whole, str(one.get("로직")))["입력"]}
except Exception: # noqa: BLE001
continue
return out
def doc_row(whole: Any, code: str) -> dict:
"""기초 머리(855 L2 ⓑ-3 · 로직 줄 안 읽음) — M01 수식 문서의 이름 · 결과단위 · 원문번호 · 입력 이름
(입력 · 선택 변수 열쇠) · M01 문서 없는 키(굳힌 사본 줄 등) = 색인 줄 그대로(없으면 엔진 틀림)."""
from M02_MasterTemplete import M02_Doc_Copy as dc # 늦게 — dc 가 이 파일을 부름
doc = dc.folder().get(str(code))
if doc is None:
return whole.logic(code)
names = [
v["열쇠"]
for v in doc.get("변수") or []
if (v.get("연결") or {}).get("갈래") in ("입력", "선택") and v.get("열쇠")
]
return {
"키": str(code),
"이름": doc.get("이름"),
"결과단위": doc.get("결과단위"),
"원문번호": dc.md.tags_of(doc).get("원문번호"),
"입력": [{"이름": n} for n in names],
}
def _logic(whole: Any, code: str, where: str) -> dict | None:
if whole is None:
return None
try:
return whole.logic(code)
return doc_row(whole, code)
except Exception as e: # noqa: BLE001 — 엔진 FormulaError(가져오기 둘레 피함)
raise DocError(f"{where} · {e}") from e
@@ -20,7 +20,7 @@
"sangeun.복사": "40edbd4d0644186f",
"sangeun.붙여넣기": "57cfb7bb522a80d3",
"sangeun.쓰는곳": "2c9ec1824709481f",
"sangeun.읽기": "19662ccd4c5ae0c0",
"sangeun.읽기": "670646670a5685b4",
"sangeun.중복": "2c9378c6e9c61251",
"sangeun.지우기": "db8b1e8ad9bef9eb",
"sangeun.합치기": "b8f7720e8a1e1bbb",