summaryrefslogtreecommitdiff
path: root/patchwork/templatetags
diff options
context:
space:
mode:
authorStephen Finucane <stephen.finucane@intel.com>2015-11-26 19:43:37 +0000
committerStephen Finucane <stephen.finucane@intel.com>2015-12-03 22:08:55 +0000
commitbcb65281b432a86ae092989e4226561830b294b1 (patch)
tree62cae79403b11ae29c70c2ac4ad7ca8e66b0bdf2 /patchwork/templatetags
parentc9ad6b85d8eaf3ead23384bb227dcc89545c42a8 (diff)
downloadpatchwork-bcb65281b432a86ae092989e4226561830b294b1.tar
patchwork-bcb65281b432a86ae092989e4226561830b294b1.tar.gz
py3: "Modernize" code base
Run code through the 'modernize' application to fix Python 3 compatibility while also retaining Python 2 backwards compatibility. There are some key changes made to the autogenerated code: * Don't wrap 'items()' in 'list' for for loops - it's not necessary * Don't wrap 'keys()' in 'list' - just drop 'keys()' * Use Django's version of six rather than the upstream one Many of the issues found are based upon the changed definitions of the map, keys and items functions, along with the removal of the iteritems function and reduce keyword. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Diffstat (limited to 'patchwork/templatetags')
-rw-r--r--patchwork/templatetags/listurl.py6
-rw-r--r--patchwork/templatetags/syntax.py9
2 files changed, 8 insertions, 7 deletions
diff --git a/patchwork/templatetags/listurl.py b/patchwork/templatetags/listurl.py
index 118fd58..7e0e3d7 100644
--- a/patchwork/templatetags/listurl.py
+++ b/patchwork/templatetags/listurl.py
@@ -39,7 +39,7 @@ class ListURLNode(template.defaulttags.URLNode):
def __init__(self, kwargs):
super(ListURLNode, self).__init__(None, [], {}, False)
self.params = {}
- for (k, v) in kwargs.iteritems():
+ for (k, v) in kwargs.items():
if k in list_params:
self.params[k] = v
@@ -68,14 +68,14 @@ class ListURLNode(template.defaulttags.URLNode):
except Exception:
pass
- for (k, v) in self.params.iteritems():
+ for (k, v) in self.params.items():
params[smart_str(k, 'ascii')] = v.resolve(context)
if not params:
return str
return str + '?' + '&'.join(
- ['%s=%s' % (k, escape(v)) for (k, v) in params.iteritems()])
+ ['%s=%s' % (k, escape(v)) for (k, v) in list(params.items())])
@register.tag
diff --git a/patchwork/templatetags/syntax.py b/patchwork/templatetags/syntax.py
index 3988f61..9d06044 100644
--- a/patchwork/templatetags/syntax.py
+++ b/patchwork/templatetags/syntax.py
@@ -24,6 +24,7 @@ import re
from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
+from django.utils.six.moves import map
register = template.Library()
@@ -32,17 +33,17 @@ def _compile(t):
(r, str) = t
return (re.compile(r, re.M | re.I), str)
-_patch_span_res = map(_compile, [
+_patch_span_res = list(map(_compile, [
('^(Index:?|diff|\-\-\-|\+\+\+|\*\*\*) .*$', 'p_header'),
('^\+.*$', 'p_add'),
('^-.*$', 'p_del'),
('^!.*$', 'p_mod'),
- ])
+ ]))
_patch_chunk_re = \
re.compile('^(@@ \-\d+(?:,\d+)? \+\d+(?:,\d+)? @@)(.*)$', re.M | re.I)
-_comment_span_res = map(_compile, [
+_comment_span_res = list(map(_compile, [
('^\s*Signed-off-by: .*$', 'signed-off-by'),
('^\s*Acked-by: .*$', 'acked-by'),
('^\s*Nacked-by: .*$', 'nacked-by'),
@@ -50,7 +51,7 @@ _comment_span_res = map(_compile, [
('^\s*Reviewed-by: .*$', 'reviewed-by'),
('^\s*From: .*$', 'from'),
('^\s*&gt;.*$', 'quote'),
- ])
+ ]))
_span = '<span class="%s">%s</span>'