feat(rust): difflib port + taxonomy data dump
- src/difflib.rs: faithful port of CPython difflib.SequenceMatcher (Ratcliff/Obershelp ratio incl. real_quick_ratio/quick_ratio and autojunk), validated against python-computed test vectors with exact float equality - data/warhammer_data.json: taxonomy tables dumped from the python module (tools/dump_warhammer_data.py), parsed order-preserving in src/warhammer_data.rs (python dict insert-order + last-value-wins semantics) - deps for the module ports: clap, reqwest, url, base64, regex, sha2, hex, sevenz-rust2, unrar, zip, indexmap, rand, rpassword
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#!/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)")
|
||||
Reference in New Issue
Block a user