fix(m01-sl): 품셈 표 바깥 값 열 차례를 Table 과 같게 — 범위 조건만 두 칸 · 값 칸은 한 칸

- 조건 칸(범위 조건은 「·아래」 「·위」) → 값 칸 · 머리 줄 포함 블록을 A1 부터(M01_SL_Table_Build layoutOf · blockCells 와 같음)
- 범위 칸에 목록이 아니면 빈 칸 · 값 칸 범위 값은 「80,100」 글(JS String 과 같음)
- 시험 견본에 값 칸 범위 · 범위 아닌 칸 더함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
This commit is contained in:
2026-10-01 13:16:21 +09:00
co-authored by Claude Opus 5.5
parent 5f9240c9e3
commit f8d7776284
2 changed files with 34 additions and 26 deletions
+16 -12
View File
@@ -161,7 +161,10 @@ def _logic(key: str, inputs: dict, field: str | None) -> dict:
def _table(key: str) -> dict:
"""품셈 표 통째 → 머리 줄 + 줄(범위 · 범위 값은 「이름·아래」 「이름·위」 두 칸)."""
"""품셈 표 통째 → 머리 줄 + 줄 — `M01_SL_Table_Build.layoutOf · blockCells` 와 같은 열 차례.
조건 칸(범위 조건은 「이름·아래」 「이름·위」 두 칸) → 값 칸(늘 한 칸 · 범위 값은 「아래,위」).
"""
files = store.loaded()[0]
table = next(
(
@@ -175,24 +178,25 @@ def _table(key: str) -> dict:
)
if table is None:
return {"ok": False, "reason": f"없는 표 「{key}」"}
names = [*(table.get("조건") or {}), *(table.get("값칸") or {})]
split = {
n
for n in names
if (table.get("조건") or {}).get(n) == "범위"
or any(isinstance(r.get(n), list) for r in table.get("줄") or [])
}
conds = table.get("조건") or {}
names = [*conds, *(table.get("값칸") or {})]
split = {n for n in conds if conds[n] == "범위"}
head = [h for n in names for h in ((n + RANGE_LOW, n + RANGE_HIGH) if n in split else (n,))]
def plain(v: Any) -> Any: # JS String(배열) 과 같게 — 「80,100」 · 빈 끝은 빈 글
if isinstance(v, list):
return ",".join("" if x is None else str(x) for x in v)
return None if v == "" else v
rows = []
for r in table.get("줄") or []:
line = []
for n in names:
v = r.get(n)
if n in split:
low, high = v if isinstance(v, list) else (v, v)
line += [low, high]
if n in split: # 범위 칸 — 목록이 아니면 둘 다 빈 칸
line += list(v) if isinstance(v, list) else [None, None]
else:
line.append(v if not isinstance(v, (list, dict)) else str(v))
line.append(plain(v))
rows.append(line)
return {"ok": True, "rows": [head, *rows], "name": table.get("이름"), "unit": table.get("기준")}