Commit 3ffc882e authored by kaiyou's avatar kaiyou

Add a jinja template renderer for notifiers

parent b22ac975
......@@ -42,7 +42,7 @@ class Scheduler(object):
state = json.loads(value) if value else {"status": True, "count": 0}
count=state["count"] + 1 if status == state["status"] else 0,
status=status, result=result
name=name, status=status, result=result
), json.dumps(state))
import importlib
import jinja2
def resolve(function, cache={}):
......@@ -8,3 +9,7 @@ def resolve(function, cache={}):
module, name = function.rsplit(".", 1)
cache[function] = getattr(importlib.import_module(module), name)
return cache[function]
def render(template, data):
return jinja2.Template(template).render(**data)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment