--- /dev/null
+ # -*- coding: utf-8 -*-
+ """
+ jinja2._compat
+ ~~~~~~~~~~~~~~
+
+ Some py2/py3 compatibility support that is not yet available in
+ "six" 1.3.0.
+ There are bugs open for "six" for all this stuff, so we can remove it
+ again from here as soon as we require a new enough "six" release.
+
+ :copyright: Copyright 2013 by the Jinja team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+ """
+
+ # https://bitbucket.org/gutworth/six/issue/25/add-unichr
+ try:
+ unichr = unichr # py2
+ except NameError:
+ unichr = chr # py3
++
++try:
++ range_type = xrange
++except NameError:
++ range_type = range
from jinja2.visitor import NodeVisitor
from jinja2.exceptions import TemplateAssertionError
from jinja2.utils import Markup, concat, escape, is_python_keyword
++from jinaj2._compat import range_type
import six
-from six.moves import cStringIO as StringIO
-from six.moves import map, zip
-from six.moves import xrange
+from six.moves import cStringIO as StringIO, map
- # TODO: Move this to the compat module.
- try:
- range_type = xrange
- except NameError:
- range_type = range
-
operators = {
'eq': '==',
"""Does the node have a safe representation?"""
if value is None or value is NotImplemented or value is Ellipsis:
return True
- if isinstance(value, (bool, int, float, complex, range_type, Markup) + six.string_types):
- if isinstance(value, (bool, int, float, complex, xrange, Markup) + six.string_types):
++ if isinstance(value, (bool, int, float, complex, range_type,
++ Markup) + six.string_types):
return True
if isinstance(value, (tuple, list, set, frozenset)):
for item in value: