From f2feb7efcd0ebf32ebebffc3dfed3c1493a904b6 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 7 Jan 2012 17:28:28 +0100 Subject: [PATCH] Normalize to styleguide --- jinja2/filters.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jinja2/filters.py b/jinja2/filters.py index 69e67e2..74f3113 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -70,23 +70,25 @@ def do_forceescape(value): value = value.__html__() return escape(unicode(value)) + def do_urlescape(value): """Escape strings for use in URLs (uses UTF-8 encoding).""" def utf8(o): return unicode(o).encode('utf8') - + if isinstance(value, basestring): return urllib.quote(utf8(value)) - + if hasattr(value, 'items'): # convert dictionaries to list of 2-tuples value = value.items() - + if hasattr(value, 'next'): # convert generators to list value = list(value) - - return urllib.urlencode([(utf8(k), utf8(v)) for (k, v) in value]) + + return urllib.urlencode((utf8(k), utf8(v)) for (k, v) in value) + @evalcontextfilter def do_replace(eval_ctx, s, old, new, count=None): -- 2.26.2