Merge remote-tracking branch 'origin/dev' into sub_laptop_3

This commit is contained in:
2026-11-18 08:37:23 +09:00
15 changed files with 162 additions and 94 deletions
+4 -2
View File
@@ -131,8 +131,10 @@ def hourly_link(eq: str, part: str) -> dict | None:
if not logic:
return None
given = {"기계": _lit(code)} if machine.takes_machine(logic) else {}
for spec in logic.get("입력") or []:
if spec.get("이름") != "기계":
from M02_MasterTemplete import M02_Labor_Inputs as li
for spec in li.specs(logic): # 문서 입력 변수(855 L2 ⓑ)
if spec["이름"] != "기계":
given[spec["이름"]] = _lit((spec.get("고르기") or [""])[0])
return {"갈래": "단가산출", "키": str(logic["키"]), "입력": given, "칸": part}
+13 -11
View File
@@ -151,11 +151,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)
@@ -185,12 +182,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] + [
@@ -199,7 +196,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
+10 -4
View File
@@ -33,15 +33,19 @@ def logic_doc(one: dict, doc: dict, whole: Any) -> dict[str, Any]:
from M02_MasterTemplete import M02_Labor_Patch as patch
from M02_MasterTemplete import M02_Sangeun_Calc as calc
from M01_MasterData import M01_MasterData_Doc as m01doc
code = str(one["로직"])
row = whole.logic(code)
m01doc.head(code) # 없는 기초 = 옛 `Master.logic` 과 같은 까닭
doc_ = m01doc.docs()[code]
row = whole.logic(code) # 호표 재료 차례 = 옛 자재표시 칸 몫(남김)
shown = dict(one.get("자재표시") or {})
for n, item in enumerate(row.get("호표") or []):
if item.get("종류") == "재료":
mine = shown.get(str(n))
shown[str(n)] = {**labor.marks(mine), "별도계상": labor.mark_of(mine, "별도계상")}
unit = calc.base_unit(row)
name = str(one.get("별칭") or row.get("이름") or code)
unit = calc.base_unit(doc_)
name = str(one.get("별칭") or doc_.get("이름") or code)
sk = patch.to_sangeun({**one, "자재표시": shown}, name, unit[1] if unit else "식", whole)
return {**sk, **{k: doc[k] for k in CARRY if doc.get(k)}}
@@ -50,9 +54,11 @@ def from_logic(code: Any, new: bool = False, use: str | None = None) -> dict[str
"""[+ 줄] M01 기초 고름 — 지금 층에 SK 사본(같은 내용 = 409 물음 · 733-2) → `{이름: SK 키, 참조}`."""
from M02_MasterTemplete import M02_Library_Ask as ask
from M01_MasterData import M01_MasterData_Doc as m01doc
whole = _whole()
try:
whole.logic(str(code))
m01doc.head(str(code))
except Exception as e: # noqa: BLE001 — 없는 로직
raise store.StoreError(400, f"없는 기초 「{code}」") from e
sk = logic_doc({"로직": str(code), "입력값": {}}, {}, whole)
+22 -7
View File
@@ -23,6 +23,8 @@
단가 = M01 기계 한 시간 값 다시 받음(736-3) · 항목 · 수량 · 입력값 · 고름 · 자재표시 · 켜쌓기율 ·
기본정보 남김 → 값 = 연결된 M01 키 값.
한 번용 옮기기(`migrate`)는 끝나 걷음(894).
기초 이름 · 결과단위 · 입력 이름 = M01 수식 문서(855 L2 ⓑ · `_doc`) · 줄 정체(cid) · 호표 재료 차례는
옛 패치 칸(덮개 · 뺀줄 · 고름 · 자재표시) 몫이라 아직 로직 줄(`compose` · `sk_line` · 옛 패치 칸 걷기 때 같이).
"""
from __future__ import annotations
@@ -33,7 +35,9 @@ import time
from decimal import Decimal
from typing import Any
from M01_MasterData import M01_MasterData_Doc as m01doc
from M02_MasterTemplete import M02_Labor_Fixed as fixed
from M02_MasterTemplete import M02_Labor_Inputs as labor_inputs
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete import M02_Sangeun_Const as const
from M02_MasterTemplete import M02_Sangeun_Doc as sd
@@ -50,6 +54,16 @@ def _whole() -> Any:
return m01.loaded()[1]
def _doc(code: Any) -> dict:
"""기초 키 → 수식 문서 · 없거나 로직 아닌 키 = 옛 `Master.logic` 과 같은 `FormulaError`."""
m01doc.head(str(code))
return m01doc.docs()[str(code)]
def _names(doc: dict) -> set[str]:
return {s["이름"] for s in labor_inputs.specs(doc)}
def _d(value: Any) -> Decimal:
return Decimal(str(value))
@@ -124,7 +138,7 @@ def filled_adds(doc: dict, whole: Any) -> list[dict]:
for one in doc.get("더한줄") or []:
if one.get("종류") == "로직":
try:
names = [str(s.get("이름")) for s in whole.logic(one["로직"]).get("입력") or []]
names = list(_names(_doc(one["로직"])))
except Exception: # noqa: BLE001 — 없는 로직 = 검사 · 셈이 까닭
names = []
mine = dict(one.get("입력값") or {})
@@ -150,8 +164,8 @@ def sk_adds(y: dict, q: Decimal, whole: Any, tag: dict) -> list[dict]:
raise sd.DocError("율 줄 있는 바탕 없는 단가산출은 펼쳐 넣지 못함 — 참조로 둠")
if not code:
return [_scaled(one, q, tag) for one in adds]
row = whole.logic(code)
names = {str(s.get("이름")) for s in row.get("입력") or []}
row = _doc(code)
names = _names(row)
unit = calc.base_unit(row)
entry: dict[str, Any] = {
"종류": "로직",
@@ -185,7 +199,7 @@ def sc_adds(z: dict, q: Decimal, whole: Any, tag: dict) -> list[dict]:
for at, one in enumerate(z.get("담은로직") or []):
n = q * _hand(one, lines.get(str(at)))
if one.get("로직"):
row = whole.logic(one["로직"])
row = _doc(one["로직"])
body = patch.as_doc(one, whole)
entry = {
"종류": "로직",
@@ -345,11 +359,12 @@ def sk_line(y: dict, one: dict, whole: Any, tag: dict) -> dict:
code = (y.get("바탕") or {}).get("로직")
if not code:
raise sd.DocError("바탕 기초 없는 단가산출은 일위대가 줄로 못 담음 — 그 안 줄을 따로 넣음")
row = whole.logic(code)
if calc.ratio_of(y, row, whole) != calc.times_of(row):
doc = _doc(code)
if calc.ratio_of(y, doc, whole) != calc.times_of(doc):
raise sd.DocError("단위 환산 단가산출은 일위대가 줄로 못 담음(값 단위가 바뀜)")
row = whole.logic(code) # 줄 정체 · 호표 재료 차례 = 옛 패치 칸 몫(남김)
ids = sd.line_ids(row)
names = {str(s.get("이름")) for s in row.get("입력") or []}
names = _names(doc)
at = {c: str(n) for n, c in enumerate(ids)}
body = {k: y[k] for k in ("덮개", "뺀줄") if y.get(k) not in EMPTY}
body |= {"더한줄": adds} if (adds := filled_adds(y, whole)) else {}
+35 -32
View File
@@ -12,16 +12,19 @@
식 고름 한 곳(822-2 · `pick`) = ㉠ 원문번호가 식 「기계」 목록에 있으면 그 식(짝 차례) ㉡ 그 기계만의 식
(`_own`) ㉢ 없으면 꼴(채운 칸 · `M02_MyMachine.logic_key`) — M01 [새 기계] · 불러오기 · 데이터 흐름 ·
줄 쌓기 · 단가산출 기초가 다 이것을 씀 · 못 고름 · 값 모자람 = 까닭 글(`why`).
식 = M01 수식 문서(`M01_MasterData_Doc` · 입력 = 문서 입력 변수 · 기계 칸 = 문서 요소 연결 · 855 L2 ⓑ) —
`pick` · `logic_of` 는 문서를 돌려줌 · `why` · `takes_machine` 은 로직 줄을 받아도 키로 문서를 읽음.
"""
from __future__ import annotations
import re
from typing import Any
import master_machine_crew as mcrew
from M01_MasterData import M01_MasterData_Doc as m01doc
from M01_MasterData import M01_MasterData_Store as store
from M02_MasterTemplete import M02_Labor_Inputs as li
from M02_MasterTemplete import M02_MyMachine as mym
cm = store.cm
@@ -33,19 +36,24 @@ _PLAIN = {
"전력 계약종별",
} # 이 밖의 입력 = 부착 장비 전용
_TEXT = {"주연료종류", "조종원직종"} # 글 칸 — 나머지 기계 줄 값 칸은 수
_FIELD = re.compile(r"EQ:\{기계\}\.([^\s*/+()\-,]+)")
_MACHINE = "EQ:{" # 문서 요소 연결 키 「EQ:{S_기계}」 = 고른 기계 줄
HOUR_UNIT = "10^-7/시간"
def _doc(logic: dict | None) -> dict:
"""로직 키 → 수식 문서(문서 · 로직 줄 무엇을 받아도 키로) · 없음 = 빈 묶음."""
return m01doc.docs().get(str((logic or {}).get("키"))) or {}
def _rows() -> list[dict]:
"""「건설기계」 장 파일 안 · 입력 「기계」 고르기가 있는 돈 로직(부착 조합 식 포함)."""
"""「건설기계」 장 문서 파일 안 · 입력 「기계」 고르기가 있는 돈 문서(부착 조합 식 포함)."""
return [
row
for name, data in store.loaded()[0].items()
if data.get("그룹") == "로직" and "건설기계" in name
for row in data.get("줄") or []
if str(row.get("결과단위") or "").startswith("원")
and any(i.get("이름") == "기계" and i.get("고르기") for i in row.get("입력") or [])
doc
for name, data in m01doc.logic_files().items()
if "건설기계" in name
for doc in data["줄"]
if str(doc.get("결과단위") or "").startswith("원")
and any(i["이름"] == "기계" and i.get("고르기") for i in li.specs(doc))
]
@@ -55,12 +63,12 @@ def _family() -> list[dict]:
def _codes(row: dict) -> list:
return next(i["고르기"] for i in row["입력"] if i.get("이름") == "기계")
return next(i["고르기"] for i in li.specs(row) if i["이름"] == "기계")
def _rank(row: dict) -> tuple:
"""부착 전용 · 손료만 · 보정 · 기종 수 · 키 — 작을수록 먼저."""
names = [i.get("이름") for i in row.get("입력") or []]
names = [i["이름"] for i in li.specs(row)]
attach = any(n not in _PLAIN for n in names)
loss = "지역" not in names
return (attach, loss, loss and "보정작업" in names, len(_codes(row)), str(row.get("키")))
@@ -100,11 +108,11 @@ def pick(row: dict) -> dict | None:
if got := _own(code):
return got
key = None if _day_loss(row) else mym.logic_key(row)
return mym.whole().logic(key) if key else None
return m01doc.docs().get(key) if key else None
op = float(_vals(row).get("조종원") or 0) > 0 or _operated(code) # 그 줄 인력도(842-3)
def order(row: dict) -> tuple:
has = any(x.get("이름") == "조종원" for x in row.get("호표") or [])
has = any(x.get("이름") == "조종원" for x in row.get("금액") or [] if "수량" in x)
rank = _rank(row)
return (*rank[:3], op and not has, *rank[3:])
@@ -113,15 +121,16 @@ def pick(row: dict) -> dict | None:
def _own(code: str) -> dict | None:
"""그 기계만의 시간당 경비 식(816-1 · 4륜구동 1톤 덤프트럭 = GF000145 · 816-3 체인톱 = GF000337) —
「기계」 입력 없는 기계경비식이 그 원문번호 기계 줄 값(`EQ….가격` · `EQ….손료계수`)을 읽으면 그 식."""
「기계」 입력 없는 기계경비식 문서가 그 원문번호 기계 줄 값(요소 연결 `EQ…` 칸)을 읽으면 그 식."""
rows = mym.whole().index.get("EQ", {}).values()
keys = [f"{r.get('키')}." for r in rows if code and str(r.get("원문번호")) == code]
for data in store.loaded()[0].values():
for row in data.get("줄") or [] if data.get("그룹") == "로직" else []:
if (row.get("부품") or {}).get("갈래") != "기계경비식" or takes_machine(row):
keys = {r.get("키") for r in rows if code and str(r.get("원문번호")) == code}
for data in m01doc.logic_files().values():
for doc in data["줄"]:
if (doc.get("부품") or {}).get("갈래") != "기계경비식" or takes_machine(doc):
continue
if any(k in str(row.get("중간")) + str(row.get("호표")) for k in keys):
return row
links = [v.get("연결") or {} for v in doc.get("변수") or []]
if any(x.get("갈래") == "요소" and x.get("키") in keys for x in links):
return doc
return None
@@ -150,10 +159,10 @@ def why(row: dict, logic: dict | None) -> str:
if float(vals.get("조종원") or 0) > 0 and not vals.get("조종원직종"):
return "조종원직종 없음"
return "손료 계수 셋(상각 · 정비 · 관리) 없음"
text = " ".join(str(x.get(k)) for k in ("식", "수량") for p in ("중간", "호표", "덧줄")
for x in logic.get(p) or []) # fmt: skip
links = [v.get("연결") or {} for v in _doc(logic).get("변수") or []]
fields = [x["칸"] for x in links if x.get("갈래") == "요소" and str(x.get("키") or "").startswith(_MACHINE) and x.get("칸")] # fmt: skip
lost, odd = [], []
for name in dict.fromkeys(_FIELD.findall(text)):
for name in dict.fromkeys(fields):
v = vals.get(name)
if v in (None, ""):
lost.append(name)
@@ -166,7 +175,7 @@ def why(row: dict, logic: dict | None) -> str:
def takes_machine(logic: dict) -> bool:
"""식이 「기계」 입력(원문번호 고르기)을 받는지 — 안 받는 식(GF000145)엔 기계='…' 를 안 넘김."""
return any(i.get("이름") == "기계" for i in logic.get("입력") or [])
return any(i["이름"] == "기계" for i in li.specs(_doc(logic)))
def hourly(key: str) -> dict[str, Any]:
@@ -268,11 +277,7 @@ def combo(main: str, part: str) -> tuple[str, str] | None:
return None
rows = _rows()
fits = any(
len(
attach := [
i for i in r.get("입력") or [] if i.get("이름") not in _PLAIN and i.get("고르기")
]
)
len(attach := [i for i in li.specs(r) if i["이름"] not in _PLAIN and i.get("고르기")])
== 1 # fmt: skip
and codes[0] in [str(c) for c in _codes(r)]
and codes[1] in [str(c) for c in attach[0]["고르기"]]
@@ -289,9 +294,7 @@ def combo(main: str, part: str) -> tuple[str, str] | None:
if not fits or row is None:
return None
given = {"기계": codes[0]} | {
i["이름"]: (i.get("고르기") or [""])[0]
for i in row.get("입력") or []
if i["이름"] != "기계"
i["이름"]: (i.get("고르기") or [""])[0] for i in li.specs(row) if i["이름"] != "기계"
}
args = "".join(f", {k}='{v}'" for k, v in given.items())
return str(row["키"]), f"로직({row['키']}{args})"
+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