Bopytex/bopytex/worker/generate.py

19 lines
443 B
Python
Raw Normal View History

2022-04-10 13:50:58 +00:00
from jinja2.environment import Template
2022-04-13 10:26:04 +00:00
from bopytex.message import Message
2022-04-10 13:50:58 +00:00
def generate(args, deps, output):
env = args["jinja2"]["environment"]
template = env.get_template(deps[0])
2022-04-13 10:26:04 +00:00
try:
with open(output, "w") as out:
fed = template.render(args)
out.write(fed)
2022-04-13 10:26:04 +00:00
return Message(0, [f"GENERATE - {deps[0]} to {output}"], [])
except Exception as e:
return Message(1, [], [e])