def get_template(string):
    '''
    Gets a jinja2 ``Template`` object for the input string, with caching based on the SHA1
    of the string.
    '''

    cache_key = sha1_hash(string)

    if cache_key in TEMPLATES:
        return TEMPLATES[cache_key]

    TEMPLATES[cache_key] = Template(string, keep_trailing_newline=True)
    return TEMPLATES[cache_key]
dataset/ETHPy150Open Fizzadar/pyinfra/pyinfra/api/util.py/get_template/original