mirror of
https://github.com/LostArtefacts/TR2X.git
synced 2025-01-09 06:50:23 +00:00
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
REPO_DIR = Path(__file__).parent.parent
|
|
RESOURCES_DIR = REPO_DIR / "tools" / "resources"
|
|
SRC_DIR = REPO_DIR / "src"
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--version-file", type=Path)
|
|
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(RESOURCES_DIR / "icon.ico"))
|
|
output_path.write_text(template)
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
if args.version_file and args.version_file.exists():
|
|
version = args.version_file.read_text().strip()
|
|
else:
|
|
version = ""
|
|
|
|
for output_path in args.output:
|
|
write_rc_template(
|
|
input_path=RESOURCES_DIR / output_path.name,
|
|
output_path=output_path,
|
|
version=version,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|