40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Attach native dispatcher evidence to the implemented Measure methods."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
manifest_path = ROOT / "docs/p6/python-api-manifest.json"
|
|
evidence_path = ROOT / "docs/p6/measure-measurement-api-dispatch.json"
|
|
methods = {
|
|
"Measurement.addReference3D",
|
|
"Measurement.has3DReferences",
|
|
"Measurement.volume",
|
|
"Measurement.clear",
|
|
"Measurement.length",
|
|
"Measurement.area",
|
|
"Measurement.delta",
|
|
"Measurement.com",
|
|
"Measurement.angle",
|
|
"Measurement.lineLineDistance",
|
|
"Measurement.planePlaneDistance",
|
|
"Measurement.radius",
|
|
}
|
|
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
evidence_hash = hashlib.sha256(evidence_path.read_bytes()).hexdigest()
|
|
matched: list[str] = []
|
|
for row in manifest.get("records", []):
|
|
if row.get("module") != "Measure" or row.get("name") not in methods:
|
|
continue
|
|
row["disposition"] = "exposed"
|
|
row["dispositionEvidence"] = ["docs/p6/measure-measurement-api-dispatch.json"]
|
|
row["dispositionReason"] = "native measure.measurementApi dispatcher executes the corresponding Measure::Measurement method fixture"
|
|
matched.append(str(row.get("id")))
|
|
if len(matched) != len(methods):
|
|
raise SystemExit(f"expected {len(methods)} Measure method records, matched {len(matched)}: {matched}")
|
|
manifest_path.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
print(json.dumps({"updated": len(matched), "evidenceSha256": evidence_hash, "ids": matched}, ensure_ascii=False))
|