Add add_filter function

This commit is contained in:
Benjamin Bertrand 2017-04-17 10:42:26 +03:00
parent 232d6ac256
commit c017b4aafc

View File

@ -20,6 +20,15 @@ EXPORT_DICT.update(rd.__dict__)
EXPORT_DICT.update(__builtins__)
def add_filter(filtername, filterfunc):
""" Append the filter to texenv
:param filtername: The filter name
:param filterfunc: The fiter function
"""
texenv.filters[filtername] = filterfunc
def update_export_dict(new_dict):
"""Update global variable with new_dict
@ -31,7 +40,7 @@ def update_export_dict(new_dict):
def feed(template, data, output="", force=0):
""" Feed template with data to output
:param template: jinja2 template with textenv environment
:param template: jinja2 template with texenv environment
:param data: Data dictionnary
:param output: name of the output file
(by default: tpl is replaced by a 2 digits number)
@ -96,7 +105,6 @@ def clean(dirname=".", garbages=["*.aux", "*.log"]):
for g in garbages:
g_files = Path(dirname).files(g)
logger.debug(f"Remove {g_files}")
print(g_files)
for g_file in g_files:
g_file.remove()