Files
Aislo/M02_MasterTemplete/M02_Table_Fill_Spec.py
T
eomsangdonandClaude Opus 5.5 7e6d3fa500 feat(M02): 배관 선택 컨테이너마다 집계표 한 줄 (PLAN 52-1b)
- 흙막이 추가 · 도수로/돌붙임 인스턴스마다 한 건 — 잇기 group_items[{link}{n}] 항목 · 그 컨테이너 값(형태 · 길이 · 높이 · 전 · 후를 열이 읽는 칸에 얹음) · 복사본 pipe@측점__{link}{n}
- 옛 값 — 컨테이너 없는 옛 관 · 인스턴스 없는 잇기는 줄 없음
- 서버 컨테이너 표 = 배관 명세 TS 짝(시험이 대조) · 700줄 한계로 M02_Table_Fill_Spec 따로
- 시험 test_52_1b_pipe_links · 52-1 화면 시나리오에 집계표 줄 수

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVPp2o6Mh2FZJr72yW3ofZ
2026-10-05 23:51:11 +09:00

64 lines
2.7 KiB
Python

"""집계표 채움 — 구조물 명세 선택 컨테이너마다 한 건 더(PLAN 52-1b).
선택 컨테이너 인스턴스(옵션 `{머리}_{n}_{항목}`)마다 같은 구조물 · 자리에 한 건 —
집계 항목 = 잇기 `group_items[{잇기}{n}]` · 복사본 `{구조물 id}__{잇기}{n}` · 옵션 = 그 컨테이너 값.
열 바인딩이 읽는 칸이 갈래마다 달라(독립 기슭막이 `form` · `length_m` … · 관 `{유입|유출}_revet_*`)
컨테이너 값을 그 칸들에 함께 얹음 — 어느 출처로 읽어도 그 컨테이너 값.
짝: `A00_Common/design/design_structure_pipe.ts` 선택 컨테이너(머리 · 잇기 · 제목) — 시험이 대조.
"""
from __future__ import annotations
import re
from typing import Any
from common_util.common_util_summary_item import GROUP_JOIN
#: 종류 → 선택 컨테이너 (머리, 잇기, 제목)
SPEC_CONTAINERS: dict[str, tuple[tuple[str, str, str], ...]] = {
"pipe": (
("soil_add", "gsoiladd", "흙막이 추가"),
("chute_add", "gchuteadd", "도수로/돌붙임"),
),
}
_TEXT = ("structure", "form")
def _as_options(values: dict[str, Any]) -> dict[str, Any]:
"""컨테이너 값 → 열이 읽는 칸 — 구조 = `structure` · `{쪽}_type` ·
나머지 = 맨 칸 + `{쪽}_revet_*`."""
out: dict[str, Any] = {}
for item, value in values.items():
if item == "structure":
out.update(structure=value, inlet_type=value, outlet_type=value)
continue
name = item if item in _TEXT else f"{item}_m"
out[name] = value
for side in ("inlet", "outlet"):
out[f"{side}_revet_{name}"] = value
return out
def container_rows(item: dict[str, Any], links: dict[str, Any]) -> list[dict[str, Any]]:
"""한 구조물의 선택 컨테이너 인스턴스마다 한 건(n 차례) — 컨테이너 없는 종류는 빈 목록."""
rows: list[dict[str, Any]] = []
for prefix, link, title in SPEC_CONTAINERS.get(item["type_id"], ()):
head = re.compile(rf"^{prefix}_(\d+)_(.+)$")
found: dict[int, dict[str, Any]] = {}
for key, value in item["options"].items():
hit = head.match(key)
if hit:
found.setdefault(int(hit.group(1)), {})[hit.group(2)] = value
for n in sorted(found):
gid = f"{link}{n}"
rows.append(
{
**item,
"options": {**item["options"], **_as_options(found[n])},
"summary_item": links.get(gid),
"복사본": f"{item['복사본']}{GROUP_JOIN}{gid}",
"그룹": f"{title} {n}",
}
)
return rows