feat(b08): 라이브러리 가져오기 목록에 항목 종류 배지 [양식형]·[고정형] — 명세 13장대로 식이 한 줄이라도 있나로만 가름(저장된 item_kind 표시는 안 믿음)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016VBGFXB9AbJBwXP19z75Qq
This commit is contained in:
@@ -44,10 +44,26 @@ def _items(folder: Path) -> list[dict[str, Any]]:
|
||||
return [json.loads(p.read_text(encoding="utf-8")) for p in sorted(folder.glob("*.json"))]
|
||||
|
||||
|
||||
def item_kind(item: dict[str, Any]) -> str:
|
||||
"""양식형(`form`) · 고정형(`fixed`) — 명세 13장: 칸은 같고 **식이 한 줄이라도 있나**로만 가름.
|
||||
저장된 `item_kind` 표시는 안 믿음 — 줄과 어긋나면 배지가 거짓이 됨."""
|
||||
return (
|
||||
"form"
|
||||
if any(str(row.get("formula") or "").strip() for row in item.get("rows") or [])
|
||||
else "fixed"
|
||||
)
|
||||
|
||||
|
||||
def list_items(dirs: dict[str, Path], type_id: str) -> list[dict[str, Any]]:
|
||||
"""가져오기 고르개 — 단마다 그 종류의 항목(단·코드·이름)."""
|
||||
"""가져오기 고르개 — 단마다 그 종류의 항목(단·코드·이름·종류)."""
|
||||
return [
|
||||
{"tier": tier, "code": item.get("code"), "name": item.get("name"), "type_id": type_id}
|
||||
{
|
||||
"tier": tier,
|
||||
"code": item.get("code"),
|
||||
"name": item.get("name"),
|
||||
"type_id": type_id,
|
||||
"kind": item_kind(item),
|
||||
}
|
||||
for tier in TIERS
|
||||
if tier in dirs
|
||||
for item in _items(dirs[tier])
|
||||
|
||||
Reference in New Issue
Block a user