52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Materialize a bounded PartDesign batch from an existing native runtime report."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> int:
|
|
if len(sys.argv) != 3:
|
|
raise SystemExit("usage: replay_partdesign_batch_manifest.py RUNTIME_JSON OUTPUT_JSON")
|
|
runtime = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
|
|
output = Path(sys.argv[2])
|
|
module = runtime.get("module")
|
|
tier = runtime.get("tier")
|
|
family = runtime.get("family")
|
|
if module != "PartDesign" or tier != "object-contract" or family not in {"generic-document-object", "geometry-recompute"}:
|
|
raise SystemExit("runtime report is not a supported PartDesign object-contract batch")
|
|
source_records = runtime.get("input", {}).get("args", {}).get("records", [])
|
|
records = []
|
|
for item in source_records:
|
|
name = item.get("name") if isinstance(item, dict) else None
|
|
if not name:
|
|
continue
|
|
api_id = item.get("apiId") if isinstance(item, dict) else None
|
|
source_path = item.get("sourcePath") if isinstance(item, dict) else None
|
|
records.append([api_id or f"obj:PartDesign:{name}", name, "planned", source_path or "src/Mod/PartDesign/App", None])
|
|
if not records or len(records) > 32:
|
|
raise SystemExit("runtime report does not contain a bounded batch")
|
|
payload = {
|
|
"schema": "freecad-web-module-function-batch/v1",
|
|
"status": "ready",
|
|
"generatedAt": runtime.get("sourceRevision"),
|
|
"taskId": runtime.get("taskId", "FW-P6-FPA-Y"),
|
|
"batchId": runtime.get("batchId"),
|
|
"strategy": "replay existing native PartDesign runtime batch",
|
|
"targetSize": len(records),
|
|
"selected": {"module": module, "tier": tier, "family": family, "recordCount": len(records), "dispositionCounts": {"planned": len(records)}},
|
|
"fields": ["id", "name", "disposition", "source", "sourceLine"],
|
|
"records": records,
|
|
"queue": [],
|
|
"boundaries": ["Replayed from an existing native runtime report; no new disposition is inferred."],
|
|
}
|
|
output.write_text(json.dumps(payload, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
|
|
print(json.dumps({"status": "ready", "batchId": payload["batchId"], "records": len(records)}))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|