fix(m01-sl): 표 블록 칸 차례를 정함대로 — 범위가 있는 칸은 조건 · 값 모두 두 칸

- 브레인 정함: 서버가 칸 차례 정본 · 조건 칸 → 값 칸 · 범위 조건 · 범위 값(「20~45」)은 「이름·아래」 「이름·위」
- 그 칸에 수 하나면 아래 · 위에 같은 수 · 빈 칸은 빈 칸 · 블록 왼위 = 「표」 바깥 알약 칸
- f8d777628(값 칸 한 칸 · 「80,100」 글)을 되돌림 · 시험 기대값 맞춤

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:28:25 +09:00
co-authored by Claude Opus 5.5
parent 34165ec66a
commit 892e156efe
2 changed files with 22 additions and 28 deletions
+11 -14
View File
@@ -161,9 +161,10 @@ def _logic(key: str, inputs: dict, field: str | None) -> dict:
def _table(key: str) -> dict:
"""품셈 표 통째 → 머리 줄 + 줄 — `M01_SL_Table_Build.layoutOf · blockCells` 와 같은 열 차례.
"""품셈 표 통째 → 머리 줄 + 줄 — 표 블록 칸 차례의 정본(브레인 정함 · 화면도 이것을 따름).
조건 칸(범위 조건은 「이름·아래」 「이름·위」 두 칸) → 값 칸(늘 한 칸 · 범위 값은 「아래,위」).
조건 칸 → 값 칸 · 범위가 있는 칸(범위 조건 · 「20~45」 같은 범위 값)은 「이름·아래」 「이름·위」
두 칸 · 그 칸에 수 하나면 아래 · 위에 같은 수 · 빈 칸은 빈 칸.
"""
files = store.loaded()[0]
table = next(
@@ -178,25 +179,21 @@ def _table(key: str) -> dict:
)
if table is None:
return {"ok": False, "reason": f"없는 표 「{key}」"}
conds = table.get("조건") or {}
conds, lines = table.get("조건") or {}, table.get("줄") or []
names = [*conds, *(table.get("값칸") or {})]
split = {n for n in conds if conds[n] == "범위"}
split = {
n for n in names if conds.get(n) == "범위" or any(isinstance(r.get(n), list) for r in lines)
}
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 []:
for r in lines:
line = []
for n in names:
v = r.get(n)
if n in split: # 범위 칸 — 목록이 아니면 둘 다 빈 칸
line += list(v) if isinstance(v, list) else [None, None]
if n in split: # 범위 칸 — 수 하나면 아래 · 위 같은 수
line += list(v) if isinstance(v, list) else [v, v]
else:
line.append(plain(v))
line.append(None if v == "" else v if not isinstance(v, dict) else str(v))
rows.append(line)
return {"ok": True, "rows": [head, *rows], "name": table.get("이름"), "unit": table.get("기준")}