1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00
maloja/dev/update_dist_files.py

29 lines
589 B
Python
Raw Normal View History

import toml
import os
import jinja2
with open("pyproject.toml") as filed:
data = toml.load(filed)
templatedir = "./dev/templates"
for root,dirs,files in os.walk(templatedir):
relpath = os.path.relpath(root,start=templatedir)
for f in files:
2022-03-10 09:00:08 +03:00
if not f.endswith('.jinja'): continue
srcfile = os.path.join(root,f)
trgfile = os.path.join(relpath,f.replace(".jinja",""))
with open(srcfile) as templatefiled:
template = jinja2.Template(templatefiled.read())
result = template.render(**data)
with open(trgfile,"w") as filed:
filed.write(result)
filed.write('\n')