2023-08-31 18:04:06 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
|
|
from pathlib import Path
|
|
|
|
|
2024-10-02 10:23:23 +02:00
|
|
|
from shared.paths import TR1Paths
|
|
|
|
from shared.versioning import generate_version
|
2024-04-09 10:45:34 +02:00
|
|
|
|
2023-08-31 18:04:06 +02:00
|
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
|
|
parser = argparse.ArgumentParser()
|
2024-04-09 10:45:34 +02:00
|
|
|
parser.add_argument("-o", "--output", type=Path, nargs="+")
|
2023-08-31 18:04:06 +02:00
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
2024-04-09 10:45:34 +02:00
|
|
|
def write_rc_template(
|
|
|
|
input_path: Path, output_path: Path, version: str
|
|
|
|
) -> None:
|
2023-08-31 18:04:06 +02:00
|
|
|
template = input_path.read_text()
|
|
|
|
template = template.replace("{version}", version)
|
2024-10-02 10:23:23 +02:00
|
|
|
template = template.replace(
|
|
|
|
"{icon_path}", str(TR1Paths.data_dir / "icon.ico")
|
|
|
|
)
|
2023-08-31 18:04:06 +02:00
|
|
|
output_path.write_text(template)
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
args = parse_args()
|
2024-10-02 10:23:23 +02:00
|
|
|
version = generate_version(1)
|
2023-08-31 18:04:06 +02:00
|
|
|
|
2024-10-02 10:23:23 +02:00
|
|
|
for output_path in args.output or []:
|
2023-08-31 18:04:06 +02:00
|
|
|
write_rc_template(
|
2024-10-02 10:23:23 +02:00
|
|
|
input_path=TR1Paths.data_dir / output_path.name,
|
2023-08-31 18:04:06 +02:00
|
|
|
output_path=output_path,
|
|
|
|
version=version,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|