- test_854_3_machine_unit_mirror — 화면 MACHINE_UNIT · 내 기계 UNITS · 빌더 UNIT 의 같은 칸 단위가 같음(㎾h 표시 바꿈 · 「주연료의 %」= % 만 규칙) · 화면 칸은 세 표 어딘가에 짝(시간당 금액 칸만 예외) - 짝 머리 글 — 단위 표(화면 · 빌더) · master_doc_link.py 가 가리키는 TS 파일 바로잡음(calc → table) · M02_Labor_Spec.py 에 화면 짝 · M02_Share_Request.py 에 화면 짝(머리 글만 · 코드 불변) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""PLAN 854-3 — 기계 칸 단위 표 셋 거울: 화면(`common_util_line_stack_unit.ts` MACHINE_UNIT) ·
|
|
내 기계(`M02_MyMachine.UNITS`) · 기계 표 빌더(`build_기계_건설품셈.UNIT`).
|
|
|
|
같은 칸 이름은 단위가 같음 — 화면 표시용 글자 바꿈(kWh → ㎾h)만 규칙으로 봄 ·
|
|
빌더의 「주연료의 %」 는 설명 붙은 % 라 % 로 봄.
|
|
세 표 어디에도 없는 TS 칸은 시간당 금액 칸(노무비 · 재료비 · 경비)뿐.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / "resources" / "master_data" / "scripts"))
|
|
|
|
from M02_MasterTemplete import M02_MyMachine as my # noqa: E402
|
|
|
|
build = importlib.import_module("build_기계_건설품셈")
|
|
|
|
MONEY_ONLY_TS = {"노무비", "재료비", "경비"}
|
|
|
|
|
|
def _ts_table() -> dict[str, str]:
|
|
src = (ROOT / "common_util" / "common_util_line_stack_unit.ts").read_text(encoding="utf-8")
|
|
body = re.search(r"MACHINE_UNIT: Record<string, string> = \{(.*?)\n\};", src, re.S)
|
|
assert body, "MACHINE_UNIT 표를 못 찾음"
|
|
return dict(re.findall(r'^\s*([^\s:]+): "([^"]*)",?$', body.group(1), re.M))
|
|
|
|
|
|
def _screen(unit: str) -> str: # 화면 표시용 글자 바꿈 — 파이썬 글 → 화면 글
|
|
return unit.replace("kWh", "㎾h").replace("주연료의 %", "%")
|
|
|
|
|
|
def test_machine_unit_tables_mirror() -> None:
|
|
ts = _ts_table()
|
|
assert len(ts) == 16
|
|
py = {"내 기계": my.UNITS, "빌더": build.UNIT}
|
|
for name, table in py.items():
|
|
for col, unit in table.items():
|
|
if not unit: # 무차원 = 화면 표 밖
|
|
continue
|
|
assert col in ts, f"{name} 칸 「{col}」 이 화면 표에 없음"
|
|
assert ts[col] == _screen(unit), f"{name} 「{col}」 단위 {unit!r} ≠ 화면 {ts[col]!r}"
|
|
for col in ts:
|
|
assert col in MONEY_ONLY_TS or any(col in t for t in py.values()), (
|
|
f"화면 칸 「{col}」 짝 없음"
|
|
)
|