21 lines
1.6 KiB
Python
21 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate the ViewProvider object runtime index from the object matrix."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
source_path = ROOT / "docs/p6/object-contract-matrix.json"
|
|
rows = json.loads(source_path.read_text(encoding="utf-8"))["records"]
|
|
selected = [row for row in rows if row["adapterFamily"] == "view-provider"]
|
|
fields = {"modules": sorted({row["module"] for row in selected}), "statuses": sorted({row["status"] for row in selected})}
|
|
lookup = {key: {value: index for index, value in enumerate(values)} for key, values in fields.items()}
|
|
records = [[row["id"], lookup["modules"][row["module"]], row["name"], lookup["statuses"][row["status"]], row["capabilities"]] for row in selected]
|
|
output = {"schema": "freecad-web-viewprovider-runtime-index/v1", "source": {"matrix": "docs/p6/object-contract-matrix.json", "matrixSha256": hashlib.sha256(source_path.read_bytes()).hexdigest()}, "count": len(records), "fields": fields, "records": records, "boundaries": ["Qt/coin ViewProvider behavior is represented by explicit Web display-state capabilities", "native mesh/shape data remains owned by module workers"]}
|
|
out = ROOT / "web/public/api/viewprovider-runtime-index.json"
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
out.write_text(json.dumps(output, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
|
|
print(json.dumps({"output": str(out.relative_to(ROOT)), "count": len(records), "bytes": out.stat().st_size, "sha256": hashlib.sha256(out.read_bytes()).hexdigest()}, ensure_ascii=False))
|