blob: 55dac9ee5b35993837ec68c36d5ba48ca935654a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
|