refactor(855-E L2a): M01 로직 목록 · 파일 · 분류 · 상세 이름표 · 별칭판 · 조합 알약을 수식 문서에서 읽음
- 관문 `M01_MasterData_Doc.logic_files` — 수식 문서 파일을 옛 로직 파일 이름으로(머리 원문 · 부문 · 차례 · 줄 = 문서) · docs() 도 같은 읽기 - /logics · /groups/로직/files · /subs?group=로직 · /elements?group=로직 · /logic 이름표 · 목록 덧칸(인재경 = 문서 금액 줄 · 작업량 = 문서 결과) · /alias 로직 줄 · 조합 알약 · 담은 로직 요약 = 문서 - 남김(쓰기 짝 · L3) — /logic 셈 칸 · prices(옛 상세 몸) · 파일 판(해) · version(저장 409) - 쓰기 마무리 — 더한 로직 줄은 문서부터(Doc.ensure · 못 지으면 빈 문서 + 머리) · 새 문서 파일 머리 = 짝 로직 파일 머리 · sync_tags 가 이름 · 결과단위 · 출처 · 부품도 같게 - 서버 답 전후 243 건 다름 0 · 조합 알약 1,558 건 다름 0 - 시험 6 파일: 마스터만 임시 사본으로 바꾸던 준비에 수식 문서 사본도(목록이 문서에서 읽으므로 사본 저장이 보이게) · test_m01_cache 한 시험의 겹친 사본 걷음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -110,23 +110,32 @@ def chapter_order(data: dict) -> int:
|
||||
return data.get("차례") or 9999
|
||||
|
||||
|
||||
def _docs():
|
||||
from M01_MasterData import M01_MasterData_Doc as doc_store # Doc 이 이 파일을 부름 — 늦게
|
||||
|
||||
return doc_store
|
||||
|
||||
|
||||
def files_of(group: str) -> list[dict]:
|
||||
"""로직 = 수식 문서 파일(855 L2 ⓐ) · 판(해) · version 은 로직 파일(저장 409 짝 · L3 에서 문서로)."""
|
||||
if group not in cm.mf.GROUPS:
|
||||
raise StoreError(404, f"없는 그룹 「{group}」")
|
||||
logic = _docs().logic_files() if group == "로직" else None
|
||||
out = []
|
||||
for name in cm.mmf.names(FOLDER):
|
||||
for name in sorted(logic) if logic is not None else cm.mmf.names(FOLDER):
|
||||
if name != f"{group}.json" and not name.startswith(f"{group}_"):
|
||||
continue
|
||||
data, version = read(name)
|
||||
head = data if logic is None else logic[name]
|
||||
out.append(
|
||||
{
|
||||
"file": name,
|
||||
"book": _book(data),
|
||||
"chapter": chapter_of(name, data),
|
||||
"book": _book(head),
|
||||
"chapter": chapter_of(name, head),
|
||||
"edition": data.get("판"),
|
||||
"rows": len(data.get(items_key(data)) or []),
|
||||
"rows": len(head.get(items_key(head)) or []),
|
||||
"version": version,
|
||||
"order": chapter_order(data),
|
||||
"order": chapter_order(head),
|
||||
}
|
||||
)
|
||||
return sorted(out, key=lambda f: (f["order"], f["file"]))
|
||||
@@ -173,7 +182,7 @@ def subs(file: str = "", group: str = "") -> dict:
|
||||
name = mk.CHAPTER.match(info["file"])
|
||||
if not name:
|
||||
continue
|
||||
data = read(info["file"])[0]
|
||||
data = _docs().logic_files()[info["file"]] if group == "로직" else read(info["file"])[0]
|
||||
kind = " ".join(x for x in (data.get("원문"), data.get("부문")) if x)
|
||||
slot = found.setdefault(kind, {"name": kind, "book": data.get("원문"), "details": []})
|
||||
slot["details"].append(mk.detail_of(info["file"]))
|
||||
@@ -335,6 +344,7 @@ def table(file: str, key: str) -> dict:
|
||||
|
||||
|
||||
def _logic_files(files: dict[str, dict]):
|
||||
"""로직 파일 줄(옛 엔진 시험 셈 `_swap` 몫 · L3 에서 걷음)."""
|
||||
for name, data in files.items():
|
||||
if data.get("그룹") == "로직":
|
||||
yield name, data
|
||||
@@ -342,11 +352,10 @@ def _logic_files(files: dict[str, dict]):
|
||||
|
||||
def logics(sub: str, detail: str, q: str, blocked: int | None, owner: str = "") -> list[dict]:
|
||||
"""로직 목록 — 구분 · 상세구분 · 소유 · 찾기로 거름(장 차례대로 · 파일을 가로지름).
|
||||
막힘은 미리 세어 둔 값(`blocks`) — 목록에서 줄마다 검사를 돌리지 않음."""
|
||||
files, _ = loaded()
|
||||
줄 = 수식 문서 머리(855 L2 ⓐ) · 막힘은 미리 세어 둔 값(`blocks`) — 목록에서 줄마다 검사를 돌리지 않음."""
|
||||
why_of = blocks()
|
||||
out = []
|
||||
for name, data in sorted(_logic_files(files), key=lambda f: chapter_order(f[1])):
|
||||
for name, data in sorted(_docs().logic_files().items(), key=lambda f: chapter_order(f[1])):
|
||||
for row in data.get("줄") or []:
|
||||
if (sub and row.get("구분") != sub) or (detail and row.get("상세구분") != detail):
|
||||
continue
|
||||
@@ -382,22 +391,22 @@ def logics(sub: str, detail: str, q: str, blocked: int | None, owner: str = "")
|
||||
|
||||
|
||||
def logic(key: str) -> dict:
|
||||
"""로직 하나 — 키는 전체에서 하나."""
|
||||
"""로직 하나 — 키는 전체에서 하나 · 있는지 · 파일 · 이름표 = 수식 문서(855 L2 ⓐ) · 셈 칸(입력 · 호표 …)
|
||||
· `prices` · `version` = 로직 파일(옛 상세 몸 · 저장 짝 — 856 · L3 에서 걷음)."""
|
||||
files, whole = loaded()
|
||||
for name, data in _logic_files(files):
|
||||
for row in data.get("줄") or []:
|
||||
if str(row.get("키")) == key:
|
||||
reasons = cache.reasons(key, whole) # 수식 문서 기준(855 2-B3)
|
||||
_, version = read(name)
|
||||
return {
|
||||
"file": name,
|
||||
"version": version,
|
||||
"logic": row,
|
||||
"blocked": bool(reasons),
|
||||
"reasons": reasons,
|
||||
"prices": _prices(whole, row),
|
||||
}
|
||||
raise StoreError(404, f"없는 로직 「{key}」")
|
||||
name, doc = _docs().find(key)
|
||||
row = next((r for r in (files.get(name) or {}).get("줄") or [] if str(r.get("키")) == key), {})
|
||||
head, named = _docs().head_of(doc), (*_docs().md.TAGS, *_docs().HEAD)
|
||||
row = {k: head.get(k, v) for k, v in row.items() if k in head or k not in named} | head
|
||||
reasons = cache.reasons(key, whole) # 수식 문서 기준(855 2-B3)
|
||||
return {
|
||||
"file": name,
|
||||
"version": read(name)[1],
|
||||
"logic": row,
|
||||
"blocked": bool(reasons),
|
||||
"reasons": reasons,
|
||||
"prices": _prices(whole, row),
|
||||
}
|
||||
|
||||
|
||||
def _brief(ref: str, row: dict) -> dict:
|
||||
@@ -451,7 +460,8 @@ def elements(group: str, q: str, limit: int) -> dict:
|
||||
if group not in cm.mf.GROUPS:
|
||||
raise StoreError(404, f"없는 그룹 「{group}」")
|
||||
hits = []
|
||||
for name, data in loaded()[0].items():
|
||||
every = _docs().logic_files() if group == "로직" else loaded()[0] # 로직 = 수식 문서(855 L2 ⓐ)
|
||||
for name, data in every.items():
|
||||
if data.get("그룹") != group:
|
||||
continue
|
||||
for row in data.get(items_key(data)) or []:
|
||||
|
||||
Reference in New Issue
Block a user