From e87c07b200bd09392d529bb486234c1a2b1fade0 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 25 Sep 2019 08:41:36 +0200 Subject: [PATCH] common (template): suppress jinja2 depreaction warning (to be removed once 2.10.1 is released) --- sat/tools/common/template.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sat/tools/common/template.py b/sat/tools/common/template.py index c7523675..4ce6a5ed 100644 --- a/sat/tools/common/template.py +++ b/sat/tools/common/template.py @@ -37,6 +37,8 @@ import pygments from pygments import lexers from pygments import formatters +log = getLogger(__name__) + try: import sat_templates except ImportError: @@ -48,7 +50,14 @@ else: sat_templates # to avoid pyflakes warning try: - import jinja2 + import warnings + + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + import jinja2 + jinja2_version = tuple([int(n) for n in jinja2.__version__.split('.')]) + if jinja2_version > (2, 10, 1): + log.warning("New jinja2 version available, warnings catches can be removed") except: raise exceptions.MissingModule( "Missing module jinja2, please install it from http://jinja.pocoo.org or with " @@ -63,8 +72,6 @@ from jinja2 import contextfilter from jinja2.loaders import split_template_path from lxml import etree -log = getLogger(__name__) - HTML_EXT = ("html", "xhtml") RE_ATTR_ESCAPE = re.compile(r"[^a-z_-]") SITE_RESERVED_NAMES = ("sat",)