# HG changeset patch # User Goffi # Date 1569393696 -7200 # Node ID 5f3068915686662efa1bea4031961b49b21bd824 # Parent d314d4181f300106fc92d34a5be84fd921c1d357 common (template): suppress jinja2 depreaction warning (to be removed once 2.10.1 is released) diff -r d314d4181f30 -r 5f3068915686 sat/tools/common/template.py --- a/sat/tools/common/template.py Mon Aug 26 09:14:58 2019 +0200 +++ b/sat/tools/common/template.py Wed Sep 25 08:41:36 2019 +0200 @@ -37,6 +37,8 @@ from pygments import lexers from pygments import formatters +log = getLogger(__name__) + try: import sat_templates except ImportError: @@ -48,7 +50,14 @@ 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.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",)