47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""Copy Orisys wheel sensor JSON configs into repo config/ (exclude options.json)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def wheel_config_dir() -> Path:
|
|
import orisys
|
|
|
|
inner_pkg = Path(orisys.__file__).resolve().parent
|
|
for candidate in (inner_pkg / "configs", inner_pkg.parent / "configs"):
|
|
if candidate.is_dir() and any(candidate.glob("*.json")):
|
|
return candidate
|
|
return inner_pkg.parent / "configs"
|
|
|
|
|
|
def sync_configs(repo_root: Path) -> int:
|
|
src = wheel_config_dir()
|
|
if not src.is_dir():
|
|
print(f"Orisys wheel configs directory not found: {src}", file=sys.stderr)
|
|
return 1
|
|
|
|
dst = repo_root / "config"
|
|
dst.mkdir(parents=True, exist_ok=True)
|
|
|
|
copied = 0
|
|
for path in sorted(src.glob("*.json")):
|
|
if path.stem.lower() == "options":
|
|
continue
|
|
shutil.copy2(path, dst / path.name)
|
|
copied += 1
|
|
|
|
print(f"Synced {copied} config(s) from {src} to {dst}")
|
|
return 0
|
|
|
|
|
|
def main() -> int:
|
|
repo_root = Path(__file__).resolve().parents[1]
|
|
return sync_configs(repo_root)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|