2022-09-29 01:59:28 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
2022-10-04 21:38:57 +00:00
|
|
|
import os
|
2022-09-29 01:59:28 +00:00
|
|
|
import yaml
|
2022-10-16 17:15:10 +00:00
|
|
|
import datetime
|
2022-09-29 01:59:28 +00:00
|
|
|
|
2022-10-04 21:38:57 +00:00
|
|
|
base_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
with open(os.path.join(base_path, "config_settings.yaml")) as file:
|
2022-09-29 01:59:28 +00:00
|
|
|
config_settings = yaml.safe_load(file)
|
|
|
|
|
2022-10-04 21:38:57 +00:00
|
|
|
with open(os.path.join(base_path, "variables.yaml")) as file:
|
2022-09-29 01:59:28 +00:00
|
|
|
variables = yaml.safe_load(file)
|
|
|
|
|
2022-10-04 21:38:57 +00:00
|
|
|
with open(os.path.join(base_path, "lua.yaml")) as file:
|
2022-09-29 01:59:28 +00:00
|
|
|
lua = yaml.safe_load(file)
|
|
|
|
|
|
|
|
data = {
|
|
|
|
"config_settings": config_settings,
|
|
|
|
"variables": variables,
|
|
|
|
"lua": lua,
|
2022-10-16 17:15:10 +00:00
|
|
|
"date": datetime.date.today().isoformat(),
|
|
|
|
"copyright_year": datetime.date.today().year,
|
2022-09-29 01:59:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
|
|
|
|
|
|
|
|
|
|
def reverse_format(param_list, format_string):
|
|
|
|
return format_string.format(param_list)
|
|
|
|
|
|
|
|
|
|
|
|
env = Environment(
|
|
|
|
loader=FileSystemLoader("."),
|
|
|
|
autoescape=select_autoescape(),
|
|
|
|
)
|
|
|
|
env.filters["reverse_format"] = reverse_format
|
|
|
|
|
|
|
|
template = env.get_template(sys.argv[1])
|
|
|
|
print(template.render(data))
|