Complete AXIS source inventory tasks

This commit is contained in:
2026-08-23 08:16:02 +08:00
parent 7b81aa9cc9
commit 9084227bf5
4 changed files with 1208 additions and 10 deletions

View File

@@ -35,6 +35,13 @@ TOOLBAR_ASSETS = (
"tool_clear.gif",
)
IMAGE_ROOT = Path("linuxcnc/share/axis/images")
CASE_ROOT = Path("linuxcnc/configs/sim/axis")
SUPPORT_ASSETS = (
"axis-16x16.png", "axis-24x24.png", "axis-32x32.png", "axis-48x48.png",
"banner.gif", "spindle_ccw.gif", "spindle_cw.gif", "std_error.gif",
"std_info.gif", "std_warning.gif",
)
DECLARATION_KEYS = ("DISPLAY", "PYVCP", "GLADEVCP", "NGCGUI", "EMBED_TAB_NAME", "EMBED_TAB_COMMAND", "HALFILE", "POSTGUI_HALFILE")
def sha256(path: Path) -> str:
@@ -88,10 +95,12 @@ def parse_axis_tcl() -> dict[str, Any]:
def asset_records() -> list[dict[str, Any]]:
result: list[dict[str, Any]] = []
for name in TOOLBAR_ASSETS:
names = list(dict.fromkeys((*TOOLBAR_ASSETS, *SUPPORT_ASSETS)))
for name in names:
path = ROOT / IMAGE_ROOT / name
result.append({
"name": name,
"role": "toolbar" if name in TOOLBAR_ASSETS else "support",
"path": (IMAGE_ROOT / name).as_posix(),
"bytes": path.stat().st_size if path.is_file() else None,
"sha256": sha256(path) if path.is_file() else None,
@@ -100,18 +109,50 @@ def asset_records() -> list[dict[str, Any]]:
return result
def case_records() -> list[dict[str, Any]]:
records: list[dict[str, Any]] = []
root = ROOT / CASE_ROOT
for path in sorted(root.rglob("*.ini")):
declarations: dict[str, str] = {}
section = ""
for raw in path.read_text(encoding="utf-8", errors="replace").splitlines():
line = raw.split("#", 1)[0].strip()
if not line:
continue
if line.startswith("[") and line.endswith("]"):
section = line[1:-1].strip().upper()
continue
if "=" not in line or section != "DISPLAY":
continue
key, value = (part.strip() for part in line.split("=", 1))
key = key.upper()
if key in DECLARATION_KEYS:
declarations[key] = value
records.append({
"path": path.relative_to(ROOT).as_posix(),
"family": "axis",
"source_sha256": sha256(path),
"declarations": declarations,
"status": "indexed",
})
return records
def generate() -> dict[str, Any]:
sources = source_records()
assets = asset_records()
cases = case_records()
axis = parse_axis_tcl()
report: dict[str, Any] = {
"schema": "axis-source-inventory.v1",
"task_id": "AXIS-INV-01",
"context_id": CONTEXT_ID,
"status": "verified" if all(row["status"] == "indexed" for row in sources + assets) else "blocked",
"implementation_status": "source_frozen",
"status": "verified" if all(row["status"] == "indexed" for row in sources + assets + cases) else "blocked",
"implementation_status": "source_frozen_and_inventory",
"completed_tasks": ["AXIS-INV-01", "AXIS-INV-02", "AXIS-INV-03", "AXIS-INV-04"],
"source": sources,
"assets": assets,
"cases": cases,
"axis_tcl": axis,
"anchors": [
{"id": "menus", "path": AXIS_TCL.as_posix(), "lines": "33-482"},
@@ -124,7 +165,10 @@ def generate() -> dict[str, Any]:
],
"checks": {
"source_paths": {"status": "verified" if all(row["status"] == "indexed" for row in sources) else "blocked"},
"toolbar_assets": {"status": "verified" if all(row["status"] == "indexed" for row in assets) else "blocked", "expected": len(TOOLBAR_ASSETS), "indexed": sum(row["status"] == "indexed" for row in assets)},
"toolbar_assets": {"status": "verified" if all(row["status"] == "indexed" for row in assets if row["role"] == "toolbar") else "blocked", "expected": len(TOOLBAR_ASSETS), "indexed": sum(row["status"] == "indexed" and row["role"] == "toolbar" for row in assets)},
"support_assets": {"status": "verified" if all(row["status"] == "indexed" for row in assets if row["role"] == "support") else "blocked", "expected": len(SUPPORT_ASSETS), "indexed": sum(row["status"] == "indexed" and row["role"] == "support" for row in assets)},
"case_paths": {"status": "verified" if cases and all(row["status"] == "indexed" for row in cases) else "blocked", "count": len(cases), "expected_baseline": 115},
"case_display_declarations": {"status": "verified" if cases and all(row["declarations"].get("DISPLAY", "axis").lower() in {"axis", "profile_axis"} for row in cases) else "blocked", "allowed": ["axis", "profile_axis"]},
"source_line_count": {"status": "verified" if axis["line_count"] == 2300 else "blocked", "expected": 2300, "actual": axis["line_count"]},
"toolbar_names_declared": {"status": "verified" if all(name.removesuffix(".gif").removesuffix(".png") in axis["toolbar_load_image_names"] for name in TOOLBAR_ASSETS if name != "tool_axis_y2.png") else "blocked"},
},

View File

@@ -21,8 +21,13 @@ class AxisSourceInventoryTests(unittest.TestCase):
self.assertEqual(report["schema"], "axis-source-inventory.v1")
self.assertEqual(report["task_id"], "AXIS-INV-01")
self.assertEqual(report["status"], "verified")
self.assertEqual(len(report["assets"]), 21)
self.assertEqual(len(report["assets"]), 31)
self.assertEqual(report["completed_tasks"], ["AXIS-INV-01", "AXIS-INV-02", "AXIS-INV-03", "AXIS-INV-04"])
self.assertEqual(report["checks"]["toolbar_assets"]["status"], "verified")
self.assertEqual(report["checks"]["support_assets"]["status"], "verified")
self.assertEqual(report["checks"]["case_paths"]["status"], "verified")
self.assertEqual(report["checks"]["case_paths"]["count"], 115)
self.assertEqual(report["checks"]["case_paths"]["expected_baseline"], 115)
self.assertEqual(report["checks"]["source_line_count"]["actual"], 2300)
self.assertGreaterEqual(report["axis_tcl"]["procedure_count"], 20)
self.assertGreaterEqual(report["axis_tcl"]["binding_count"], 10)