magicciv/tools/fauna-derive-check.py
Natalie 3c76b6b47b fix(@projects/@magic-civilization): 🐛 update fauna species data files
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-05-04 07:12:33 -04:00

39 lines
1 KiB
Python
Executable file

#!/usr/bin/env python3
"""Pre-commit gate: fail if any fauna species has stale derived combat stats.
Thin wrapper around `fauna-derive-stats.py --check`. Exit 0 means every
species file's derived combat block matches what the formulas produce. Exit 1
means a hand-edit drifted from the derivation; the printed fix-up command
re-runs the deriver.
Wire-up (recommended `.git/hooks/pre-commit` snippet):
#!/usr/bin/env bash
set -e
python3 tools/fauna-derive-check.py
"""
from __future__ import annotations
import sys
from pathlib import Path
# Re-use the deriver in --check mode.
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
# Hyphenated module name — load via importlib.
import importlib.util # noqa: E402
_spec = importlib.util.spec_from_file_location(
"fauna_derive_stats", HERE / "fauna-derive-stats.py"
)
_mod = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(_mod)
def main() -> int:
return _mod.process(check_only=True)
if __name__ == "__main__":
sys.exit(main())