bin/create-repository-zip.py
#!/usr/bin/env python3
"""Lokaler Runtime-Aufruf der ZIP-Erzeugung aus engineering-tools."""
from __future__ import annotations
import argparse, json, subprocess, sys
from pathlib import Path
def main() -> int:
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--config', type=Path, required=True)
parser.add_argument('--runtime-root', type=Path, default=Path(__file__).resolve().parents[1])
args=parser.parse_args()
cfg=json.loads(args.config.read_text(encoding='utf-8'))
root=args.runtime_root.resolve()
tool=(root/cfg['tool']).resolve() if not Path(cfg['tool']).is_absolute() else Path(cfg['tool'])
source=(root/cfg['source']).resolve(); output=(root/cfg['output']).resolve()
command=[sys.executable,str(tool),str(source),str(output)]
for pattern in cfg.get('exclude',[]): command += ['--exclude',pattern]
return subprocess.run(command,check=False).returncode
if __name__=='__main__': raise SystemExit(main())