Files
aigc-home/docs/hel-892/batch179-correction/render_current.py
T

40 lines
1.3 KiB
Python

"""Regenerate only the two authorized current documents, using existing project report code."""
import importlib.util
import json
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
ROOT = HERE.parents[2]
OLD = ROOT / "docs/hel-892/batch179-target-snapshots"
PREVIEW = ROOT / ".local-evidence/batch179-correction/report-preview"
def generate():
PREVIEW.mkdir(exist_ok=False)
for name in ("installation-matrix.json", "summary.json"):
with (PREVIEW / name).open("xb") as stream:
stream.write((OLD / name).read_bytes())
sys.path.insert(0, str(OLD))
spec = importlib.util.spec_from_file_location("current179report", OLD / "report.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
module.HERE = PREVIEW
def write(name, value):
with (PREVIEW / name).open("x", encoding="utf-8") as stream:
json.dump(value, stream, ensure_ascii=False, indent=2)
stream.write("\n")
module.write = write
module.main()
return PREVIEW
if __name__ == "__main__":
preview = generate()
for filename in ("离线安装比对说明.md", "next-step-plan.json"):
(OLD / filename).write_bytes((preview / filename).read_bytes())
print("only authorized current Chinese report and plan regenerated; data inputs unchanged")