2022-09-26 14:35:52 +01:00
|
|
|
import glob, importlib, sys
|
2022-09-23 21:57:08 +01:00
|
|
|
|
|
|
|
with open("setup-template.py", "r") as f:
|
|
|
|
setup_template = f.read()
|
|
|
|
|
|
|
|
directories = glob.glob("*/", recursive=False)
|
|
|
|
|
2022-09-26 14:35:52 +01:00
|
|
|
if len(sys.argv) >= 2:
|
|
|
|
directories = sys.argv[1:]
|
|
|
|
|
2022-09-23 21:57:08 +01:00
|
|
|
for directory in directories:
|
|
|
|
current_setup_template = setup_template
|
|
|
|
with open(f"{directory}/manifest.dat", "r") as f:
|
2022-09-26 14:35:52 +01:00
|
|
|
manifest_info = [line_info.split("\n@ ").rstrip("\n") for line_info in f.read().split("%")]
|
2022-09-23 21:57:08 +01:00
|
|
|
|
|
|
|
for replacement in manifest_info:
|
|
|
|
if len(replacement) == 2:
|
|
|
|
replacement.append(-1)
|
|
|
|
|
|
|
|
current_setup_template.replace(replacement[0], replacement[1], int(replacement[2]))
|
|
|
|
|
|
|
|
if glob.glob(f"{directory}/parser.py"):
|
|
|
|
should_continue = input(f"Custom instructions found in {directory}, continue? (Y/N) ")
|
|
|
|
if should_continue == "Y":
|
|
|
|
parser = importlib.import_module(f"{directory}/parser.py")
|
|
|
|
current_setup_template = parser.parse_template(current_setup_template)
|
|
|
|
else:
|
|
|
|
continue
|
|
|
|
|
|
|
|
with open(f"{directory}/setup.py", "w") as f:
|
|
|
|
f.write(current_setup_template)
|