TRX/tools/generate_version

33 lines
887 B
Text
Raw Normal View History

2021-11-12 21:26:26 +01:00
#!/usr/bin/env python3
import argparse
from pathlib import Path
REPO_DIR = Path(__file__).parent.parent
2022-05-13 00:56:28 +02:00
RESOURCES_DIR = REPO_DIR / "tools" / "resources"
2021-11-12 21:26:26 +01:00
SRC_DIR = REPO_DIR / "src"
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("--version")
2021-12-07 18:19:14 +01:00
parser.add_argument("--output", type=Path, nargs="+")
2021-11-12 21:26:26 +01:00
return parser.parse_args()
2021-12-07 18:19:14 +01:00
def write_rc_template(output_path: Path, args: argparse.Namespace) -> None:
2022-05-13 00:56:28 +02:00
input_path = RESOURCES_DIR / output_path.name
2021-12-07 18:19:14 +01:00
template = input_path.read_text()
template = template.replace("{version}", args.version)
2022-05-13 00:56:28 +02:00
template = template.replace("{icon_path}", str(RESOURCES_DIR / "icon.ico"))
2021-12-07 18:19:14 +01:00
output_path.write_text(template)
2021-11-12 21:26:26 +01:00
def main() -> None:
args = parse_args()
2021-12-07 18:19:14 +01:00
for output in args.output:
write_rc_template(output, args)
2021-11-12 21:26:26 +01:00
if __name__ == "__main__":
main()