summaryrefslogtreecommitdiff
path: root/modules/codenames_generate.py
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2026-02-01 00:36:11 +0100
committerBotond Hende <nettingman@gmail.com>2026-02-01 00:36:11 +0100
commitcc6bdc68cb3ed40a6e51f885ea1c7c7a4e5fa6c5 (patch)
tree144ef9f11acd0b16b518c1ea55b548a6ed21430d /modules/codenames_generate.py
parentaaee49cca9e771a7e0fbbdfe513711e94b4ff19a (diff)
codenames grid generator wipfeature/codenames
Diffstat (limited to 'modules/codenames_generate.py')
-rw-r--r--modules/codenames_generate.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/codenames_generate.py b/modules/codenames_generate.py
new file mode 100644
index 0000000..55dac9e
--- /dev/null
+++ b/modules/codenames_generate.py
@@ -0,0 +1,32 @@
+import os.path
+import shutil
+import jinja2
+
+from ..config import Config
+import os.path
+import shutil
+
+import jinja2
+
+from ..config import Config
+
+
+def generate(jinja_env: jinja2.Environment, output_root_path: str, local: bool):
+ if os.path.exists(output_root_path):
+ shutil.rmtree(output_root_path)
+
+ os.mkdir(output_root_path)
+
+ jinja_env.globals.update(codenames={
+ "codenames_url": Config.CODENAMES_ROOT_URL,
+ })
+
+ root_template = jinja_env.get_template("codenames_root.html.j2")
+ with open(os.path.join(output_root_path, "index.html"), "w") as f:
+ f.write(root_template.render({"ctx" : Config.CODENAMES_ROOT_URL, "title": Config.CODENAMES_NAME}))
+
+ duet_template = jinja_env.get_template("codenames_duet.html.j2")
+ with open(os.path.join(output_root_path, "duet.html"), "w") as f:
+ f.write(duet_template.render({"ctx" : Config.CODENAMES_ROOT_URL + "duet.html", "title": Config.CODENAMES_NAME}))
+
+ shutil.copytree(Config.CODENAMES_ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH) \ No newline at end of file