util.py 404 Bytes
Newer Older
kaiyou's avatar
kaiyou committed
1
import importlib
2
import jinja2
kaiyou's avatar
kaiyou committed
3 4 5 6 7 8 9 10 11


def resolve(function, cache={}):
    """ Utility function that resolves a fully qualified function name
    """
    if function not in cache:
        module, name = function.rsplit(".", 1)
        cache[function] = getattr(importlib.import_module(module), name)
    return cache[function]
12 13 14 15


def render(template, data):
    return jinja2.Template(template).render(**data)