from jinja2 import Environment, FileSystemLoader, select_autoescape import os, markdown2 import json, msgpack, subprocess import shutil from distutils.dir_util import copy_tree env = Environment(loader=FileSystemLoader("templates")) # subprocess.check_call("mmdc -i * -e png") # TODO: Generating mmd from docstrings for path in os.listdir("diagrams/markdown"): fname = path.split(".")[0] try: subprocess.check_call( "mmdc -i diagrams/markdown/{0} -o res/img/diagrams/{1}.png".format( path, fname ), shell=True, ) except Exception as e: print("Empty file or other error") copy_tree("diagrams/markdown", "res/diagrams") copy_tree("res", "build/res") shutil.copyfile("htmx-extensions/src/ws/ws.js", "build/res/js/ws.js") tpath = "templates/" for path in os.listdir(tpath): if ("base" in path) != True: for t in os.listdir(tpath + path): if os.path.exists("build/" + path) != True: os.makedirs("build/" + path) ipath = tpath + path + "/" + t template = env.get_template(path + "/" + t) with open("build/{0}/{1}".format(path, t), "w") as f: f.write(template.render())