43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from argparse import ArgumentParser, FileType
|
|
from base64 import b64encode
|
|
|
|
__author__ = "Cheri Dawn"
|
|
__copyright__ = "Copyright 2024, Cheri Dawn"
|
|
__license__ = "GPLv3"
|
|
__version__ = "0.2.0"
|
|
__maintainer__ = "Cheri Dawn"
|
|
__status__ = "Prototype"
|
|
|
|
if __name__ == "__main__":
|
|
parser = ArgumentParser(
|
|
description="SETAGE, the Simple Extensible Text Adventure Game Engine")
|
|
parser.add_argument("file", nargs="?", default="manifest.setage",
|
|
type=FileType("r"),
|
|
help="The manifest.setage file "
|
|
"to generate a script for.")
|
|
parser.add_argument("template", nargs="?",
|
|
default="setage-standalone.py.template",
|
|
type=FileType("r"),
|
|
help="The template for the script.")
|
|
parser.add_argument("output", nargs="?", default="setage-standalone.py",
|
|
type=FileType("w"),
|
|
help="The output file.")
|
|
|
|
args = parser.parse_args()
|
|
print(f"Reading manifest '{args.file.name}'...")
|
|
data = args.file.read()
|
|
print(f"Read manifest '{args.file.name}'.")
|
|
|
|
print(f"Reading template '{args.template.name}'...")
|
|
template = args.template.read()
|
|
print(f"Read template '{args.template.name}'.")
|
|
|
|
out = template.replace("{{data}}",
|
|
b64encode(data.encode("utf-8")).decode("utf-8"))
|
|
|
|
print(f"Writing output '{args.output.name}'...")
|
|
output = args.output.write(out)
|
|
print(f"Wrote output '{args.output.name}'.")
|