TR2X/tools/generate_rcfile
2024-04-30 11:01:52 +02:00

38 lines
940 B
Python
Executable File

#!/usr/bin/env python3
import argparse
from pathlib import Path
from libtrx.versioning import generate_version
from tr2x.paths import TR2X_DATA_DIR
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", type=Path, nargs="+")
return parser.parse_args()
def write_rc_template(
input_path: Path, output_path: Path, version: str
) -> None:
template = input_path.read_text()
template = template.replace("{version}", version)
template = template.replace("{icon_path}", str(TR2X_DATA_DIR / "icon.ico"))
output_path.write_text(template)
def main() -> None:
args = parse_args()
version = generate_version()
for output_path in args.output:
write_rc_template(
input_path=TR2X_DATA_DIR / output_path.name,
output_path=output_path,
version=version,
)
if __name__ == "__main__":
main()