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:
|
2022-05-09 07:09:38 +00:00
|
|
|
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:
|
2022-05-09 07:09:38 +00:00
|
|
|
return Message(1, [], [e])
|