纯标准库实现,对齐 PRD 5.5「⑤ 配置化驾驶舱」iAOP-cockpit-layout-v1: - cockpit.ti.yaml:海绵钛四状态工艺流程(氯化→精制→还原→蒸馏), process_view 主视图声明 stages 覆盖,trend/kpi_card bind 对齐 point_dict.default.csv 的 point_id(CLF-01/RF-01/E-01/ST-01)。 - layout_validator.py:LayoutValidator 校验 widget 类型合法、12 列网格 不越界、bind point_id 在点位字典内、四状态覆盖完整(order 单调/id 唯一); 零依赖 YAML 子集解析(复制 impurity-forecast _parse_yaml_subset)。 - tests:18 用例覆盖真实资产端到端、非法类型、网格越界/负坐标/零宽、 bind 漂移、缺 process_view、缺必需状态、order 非单调、stage 重复、 $schema 头、CSV 加载、空布局。 - _sanity_check.py:冒烟验证 9 widgets 全校验通过。
34 lines
1018 B
Python
34 lines
1018 B
Python
# -*- coding: utf-8 -*-
|
||
"""海绵钛驾驶舱布局冒烟脚本(Issue #55)。
|
||
|
||
直接运行 ``python _sanity_check.py`` 验证:cockpit.ti.yaml + point_dict.default.csv
|
||
端到端校验通过(widget 类型/网格/bind/四状态全覆盖)。零第三方依赖。
|
||
"""
|
||
import os
|
||
import sys
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
sys.path.insert(0, HERE)
|
||
|
||
from layout_validator import LayoutValidator # noqa: E402
|
||
|
||
LAYOUT_YAML = os.path.join(HERE, "cockpit.ti.yaml")
|
||
POINT_DICT_CSV = os.path.join(
|
||
HERE, os.pardir, "point-dict", "point_dict.default.csv")
|
||
|
||
|
||
def main() -> int:
|
||
report = LayoutValidator(LAYOUT_YAML, POINT_DICT_CSV).validate()
|
||
if not report.passed:
|
||
print("FAIL")
|
||
for issue in report.errors:
|
||
print(f" - [{issue.widget_id}] {issue.field}: {issue.reason}")
|
||
return 1
|
||
print(f"OK: {report.widget_count} widgets,"
|
||
f"类型/网格/bind/四状态校验通过")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|