Skip to content
Myr

improved python2.3 support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 6180279 · Browse files · 4 files+9 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+9 added−6 removed

  • tests:+3 added−3 removed
  • other:+6 added−3 removed

4 files+9 added−6 removed

modified:jinja/filters.py+4 added-1 removed
8 unmodified lines
9 :license: BSD, see LICENSE for more details.10"""11import re12from random import choice13try:13from operator import itemgetter14 from operator import itemgetter15except ImportError:16 itemgetter = lambda a: lambda b: b[a]17from urllib import urlencode, quote18from jinja.utils import urlize, escape, reversed, sorted, groupby, \19 get_attribute, pformat20from jinja.datastructure import TemplateData
969 unmodified lines
modified:jinja/lexer.py+1 added-1 removed
43 unmodified lines
44string_re = re.compile(r"('([^'\\]*(?:\\.[^'\\]*)*)'"45 r'|"([^"\\]*(?:\\.[^"\\]*)*)")(?ms)')46integer_re = re.compile(r'\d+')47float_re = re.compile(r'\d+\.\d+')48regex_re = re.compile(r'@/([^/\\]*(?:\\.[^/\\]*)*)*/[a-z]*(?ms)')48regex_re = re.compile(r'\@/([^/\\]*(?:\\.[^/\\]*)*)*/[a-z]*(?ms)')495051# set of used keywords52keywords = set(['and', 'block', 'cycle', 'elif', 'else', 'endblock',
461 unmodified lines
modified:jinja/loaders.py+1 added-1 removed
148 unmodified lines
149 return method(self, name, *args, **kw)150 try:151 new_method.__name__ = method.__name__152 new_method.__doc__ = method.__doc__153 except AttributeError:153 except:154 pass155 return new_method156157 get_source = _controlled(LoaderWrapper.get_source)
668 unmodified lines
modified:tests/test_syntax.py+3 added-3 removed
26 unmodified lines
27GROUPING = '''{{ (true and false) or (false and true) and not false }}'''28CONDEXPR = '''{{ 0 if true else 1 }}'''29DJANGOATTR = '''{{ [1, 2, 3].0 }}'''30FILTERPRIORITY = '''{{ "foo"|upper + "bar"|upper }}'''31REGEX = '''{{ @/\S+/.findall('foo bar baz') }}'''31REGEX = r'''{{ @/\S+/.findall('foo bar baz') }}'''32TUPLETEMPLATES = [33 '{{ () }}',34 '{{ (1, 2) }}',35 '{{ (1, 2,) }}',
73 unmodified lines
109110111def test_literals(env):112 tmpl = env.from_string(LITERALS)113 assert tmpl.render() == '[]|{}|()||set([])'113 assert tmpl.render().lower() == '[]|{}|()||set([])'114115116def test_bool(env):117 tmpl = env.from_string(BOOL)
55 unmodified lines
173174175def test_trailing_comma(env):176 tmpl = env.from_string(TRAILINGCOMMA)177 assert tmpl.render() == '(1, 2)|[1, 2]|{1: 2}|set([1, 2])'177 assert tmpl.render().lower() == '(1, 2)|[1, 2]|{1: 2}|set([1, 2])'178179180def test_extends_position():181 env = Environment(loader=DictLoader({
17 unmodified lines