From c017b4aafcdef4aac201d05354665cc5e8ad01d2 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Mon, 17 Apr 2017 10:42:26 +0300 Subject: [PATCH] Add add_filter function --- pytex/pytex.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pytex/pytex.py b/pytex/pytex.py index 8e327df..23fde5b 100644 --- a/pytex/pytex.py +++ b/pytex/pytex.py @@ -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()