create options files on WebHost startup

This commit is contained in:
Fabian Dill
2021-07-22 18:21:31 +02:00
parent df9bad75ea
commit 34ff5d9662
5 changed files with 120 additions and 21 deletions

17
WebHostLib/options.py Normal file
View File

@@ -0,0 +1,17 @@
import os
from Utils import __version__
from jinja2 import Template
import yaml
from worlds.AutoWorld import AutoWorldRegister
target_folder = os.path.join("WebHostLib", "static", "generated")
def create():
for game_name, world in AutoWorldRegister.world_types.items():
res = Template(open(os.path.join("WebHostLib", "templates", "options.yaml")).read()).render(
options=world.options, __version__ = __version__, game=game_name, yaml_dump = yaml.dump
)
with open(os.path.join(target_folder, game_name+".yaml"), "w") as f:
f.write(res)