Commit 1329184d authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Use map() instead of the deprecated imap().

parent ee4bf88e
......@@ -9,7 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
import re
from itertools import imap
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
......@@ -92,7 +91,7 @@ class Markup(unicode):
def __mod__(self, arg):
if isinstance(arg, tuple):
arg = tuple(imap(_MarkupEscapeHelper, arg))
arg = tuple(map(_MarkupEscapeHelper, arg))
else:
arg = _MarkupEscapeHelper(arg)
return self.__class__(unicode.__mod__(self, arg))
......@@ -104,7 +103,7 @@ class Markup(unicode):
)
def join(self, seq):
return self.__class__(unicode.join(self, imap(escape, seq)))
return self.__class__(unicode.join(self, map(escape, seq)))
join.__doc__ = unicode.join.__doc__
def split(self, *args, **kwargs):
......
......@@ -12,7 +12,7 @@ import re
import math
from random import choice
from operator import itemgetter
from itertools import imap, groupby
from itertools import groupby
from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode
from jinja2.runtime import Undefined
from jinja2.exceptions import FilterArgumentError, SecurityError
......@@ -279,11 +279,11 @@ def do_join(eval_ctx, value, d=u'', attribute=None):
The `attribute` parameter was added.
"""
if attribute is not None:
value = imap(make_attrgetter(eval_ctx.environment, attribute), value)
value = map(make_attrgetter(eval_ctx.environment, attribute), value)
# no automatic escaping? joining is a lot eaiser then
if not eval_ctx.autoescape:
return unicode(d).join(imap(unicode, value))
return unicode(d).join(map(unicode, value))
# if the delimiter doesn't have an html representation we check
# if any of the items has. If yes we do a coercion to Markup
......@@ -302,7 +302,7 @@ def do_join(eval_ctx, value, d=u'', attribute=None):
return d.join(value)
# no html involved, to normal joining
return soft_unicode(d).join(imap(soft_unicode, value))
return soft_unicode(d).join(map(soft_unicode, value))
def do_center(value, width=80):
......@@ -687,7 +687,7 @@ def do_sum(environment, iterable, attribute=None, start=0):
attributes. Also the `start` parameter was moved on to the right.
"""
if attribute is not None:
iterable = imap(make_attrgetter(environment, attribute), iterable)
iterable = map(make_attrgetter(environment, attribute), iterable)
return sum(iterable, start)
......
......@@ -8,7 +8,7 @@
:copyright: (c) 2010 by the Jinja Team.
:license: BSD.
"""
from itertools import chain, imap
from itertools import chain
from jinja2.nodes import EvalContext, _context_function_types
from jinja2.utils import Markup, partial, soft_unicode, escape, missing, \
concat, internalcode, next, object_type_repr
......@@ -34,7 +34,7 @@ identity = lambda x: x
def markup_join(seq):
"""Concatenation that escapes if necessary and converts to unicode."""
buf = []
iterator = imap(soft_unicode, seq)
iterator = map(soft_unicode, seq)
for arg in iterator:
buf.append(arg)
if hasattr(arg, '__html__'):
......@@ -44,7 +44,7 @@ def markup_join(seq):
def unicode_join(seq):
"""Simple args to unicode conversion and concatenation."""
return concat(imap(unicode, seq))
return concat(map(unicode, seq))
def new_context(environment, template_name, blocks, vars=None,
......
......@@ -16,14 +16,13 @@ try:
except ImportError:
from dummy_thread import allocate_lock
from collections import deque
from itertools import imap
_word_split_re = re.compile(r'(\s+)')
_punctuation_re = re.compile(
'^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$' % (
'|'.join(imap(re.escape, ('(', '<', '&lt;'))),
'|'.join(imap(re.escape, ('.', ',', ')', '>', '\n', '&gt;')))
'|'.join(map(re.escape, ('(', '<', '&lt;'))),
'|'.join(map(re.escape, ('.', ',', ')', '>', '\n', '&gt;')))
)
)
_simple_email_re = re.compile(r'^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment