diff --git a/M02_MasterTemplete/M02_Hopyo_Clause.py b/M02_MasterTemplete/M02_Hopyo_Clause.py index c33ac48c0..d84115bf3 100644 --- a/M02_MasterTemplete/M02_Hopyo_Clause.py +++ b/M02_MasterTemplete/M02_Hopyo_Clause.py @@ -12,6 +12,7 @@ import re from functools import lru_cache from typing import Any +from M01_MasterData import M01_MasterData_Doc as m01_doc from M01_MasterData import M01_MasterData_Store as m01 from M01_MasterData import M01_MasterData_Store_Make as make @@ -62,14 +63,12 @@ def _sections(book: str) -> dict[tuple[str, str], str]: @lru_cache(maxsize=2) -def _named(whole_id: int) -> dict[tuple[str, str], list[str]]: - """{(구분, 원문번호): [로직 이름]} — M01 로직.""" +def _named(whole_id: int, docs_id: int) -> dict[tuple[str, str], list[str]]: + """{(구분, 원문번호): [기초 이름]} — M01 수식 문서 이름표(855 L1 · `M01_MasterData_Doc.docs`).""" out: dict[tuple[str, str], list[str]] = {} - for data in m01.loaded()[0].values(): - if data.get("그룹") == "로직": - for row in data.get("줄") or []: - key = (str(row.get("구분") or ""), str(row.get("원문번호") or "").split(" ")[0]) - out.setdefault(key, []).append(str(row.get("이름") or "")) + for doc in m01_doc.docs().values(): + key = (str(doc.get("구분") or ""), str(doc.get("원문번호") or "").split(" ")[0]) + out.setdefault(key, []).append(str(doc.get("이름") or "")) return out @@ -79,7 +78,7 @@ def _part(number: str, name: Any, text: Any = "") -> str: 둘 이상 = 모름 · 없음 = 「(옛)」(번호 뜻 안 맞음).""" if not _grams(name): return "건설품셈" - named = _named(id(m01.loaded()[1])) + named = _named(id(m01.loaded()[1]), id(m01_doc.docs())) texts = { part: [title, *named.get((f"건설품셈 {part}", no), [])] for (part, no), title in _sections("건설품셈").items() diff --git a/M02_MasterTemplete/M02_Hopyo_Match.py b/M02_MasterTemplete/M02_Hopyo_Match.py index 8812f201f..1f6c8e65c 100644 --- a/M02_MasterTemplete/M02_Hopyo_Match.py +++ b/M02_MasterTemplete/M02_Hopyo_Match.py @@ -17,6 +17,7 @@ from functools import lru_cache from pathlib import Path from typing import Any +from M01_MasterData import M01_MasterData_Doc as m01_doc from M01_MasterData import M01_MasterData_Store as m01 from M01_MasterData import M01_MasterData_Store_Combo as combo_store from M02_MasterTemplete import M02_Mat_Place as place @@ -206,10 +207,10 @@ def _grams(text: str) -> set[str]: @lru_cache(maxsize=2) -def _targets(whole_id: int) -> dict[str, Any]: - """로직(돈) · 자재품목 — 정규 이름 · 정리 이름 · 묶음 · 단위.""" - files, whole = m01.loaded() - rows = [r for d in files.values() if d.get("그룹") == "로직" for r in d.get("줄") or []] +def _targets(whole_id: int, docs_id: int) -> dict[str, Any]: + """기초(돈) · 자재품목 — 정규 이름 · 정리 이름 · 묶음 · 단위 · 기초 이름표 = M01 수식 문서(855 L1).""" + whole = m01.loaded()[1] + rows = list(m01_doc.docs().values()) pills = combo_store.combo_pills({"담은로직": [{"로직": r.get("키")} for r in rows]})["물량"] unit_of = {code: pill["단위"] for pill in pills for code in pill["로직"]} # 돈 로직만 logics, mats = [], [] @@ -253,7 +254,7 @@ def _targets(whole_id: int) -> dict[str, Any]: def targets() -> dict[str, Any]: - return _targets(id(m01.loaded()[1])) + return _targets(id(m01.loaded()[1]), id(m01_doc.docs())) def _seeds() -> dict[str, set[str]]: diff --git a/M02_MasterTemplete/M02_Hopyo_Units.py b/M02_MasterTemplete/M02_Hopyo_Units.py index 9afeee449..825636c5a 100644 --- a/M02_MasterTemplete/M02_Hopyo_Units.py +++ b/M02_MasterTemplete/M02_Hopyo_Units.py @@ -20,6 +20,7 @@ from __future__ import annotations import re from typing import Any +from M01_MasterData import M01_MasterData_Doc as m01_doc from M02_MasterTemplete import M02_Hopyo_Elem as elem from M02_MasterTemplete import M02_Hopyo_Fixed as hfix from M02_MasterTemplete import M02_Elem_Alias as ea @@ -66,11 +67,12 @@ def mach_logics(whole: Any, kinds: set, eq: dict | None = None) -> list[str]: has = mcrew.view(eq.get("값")) if isinstance(eq.get("값"), dict) else {} if solo := SOLO.get((bool(has.get("주연료")), bool(has.get("조종원")))): return [solo] - eqs = whole.numbers.get("EQ", {}) + eqs, docs = whole.numbers.get("EQ", {}), m01_doc.docs() - def takes(code: str) -> bool: - ins = whole.logic(code).get("입력") or [] - opts = next((s.get("고르기") or [] for s in ins if s.get("이름") == MACH_IN), []) + def takes(code: str) -> bool: # 기초 수식 문서 기계 고르기 변수(855 L1) 목록 + ins = (docs.get(code) or {}).get("변수") or [] + pick = [(s.get("연결") or {}) for s in ins if s.get("이름") == MACH_IN] + opts = next((p.get("목록") or [] for p in pick if p.get("갈래") == "선택"), []) same = any((eqs.get(o) or {}).get("이름") == eq.get("이름") for o in opts) return eq.get("원문번호") in opts or same