#!/usr/bin/env python3 """Regenerate version-rust/data/warhammer_data.json from the python module. Run from the repo root (the version containing the python layout): python3 version-rust/tools/dump_warhammer_data.py The Rust rewrite parses this file (src/warhammer_data.rs) instead of holding a hand-transcribed copy of the taxonomy tables, so the two versions work from byte-identical data. """ import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent / "version-python")) from dlphelper import warhammer_data as w # noqa: E402 out = Path(__file__).resolve().parent.parent / "data" / "warhammer_data.json" payload = { "systems": w.SYSTEMS, "classes": [[name, keywords] for name, keywords in w.CLASSES], "group_of_faction": w.GROUP_OF_FACTION, } out.write_text(json.dumps(payload, ensure_ascii=False, indent=1), encoding="utf-8") print(f"wrote {out} ({out.stat().st_size} bytes)")