diff mbox

[v2,05/16] trivial: Resolve some PEP8 issues

Message ID 1440167540-8751-6-git-send-email-stephen.finucane@intel.com
State Accepted
Headers show

Commit Message

Stephen Finucane Aug. 21, 2015, 2:32 p.m. UTC
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
 patchwork/requestcontext.py       | 40 ++++++++++++++++++++-------------------
 patchwork/templatetags/listurl.py | 20 ++++++++++----------
 patchwork/templatetags/patch.py   |  4 ++--
 3 files changed, 33 insertions(+), 31 deletions(-)
diff mbox

Patch

diff --git a/patchwork/requestcontext.py b/patchwork/requestcontext.py
index 3652edc..8ad6049 100644
--- a/patchwork/requestcontext.py
+++ b/patchwork/requestcontext.py
@@ -24,29 +24,31 @@  from django.conf import settings
 from patchwork.filters import Filters
 from patchwork.models import Bundle, Project
 
+
 def bundle(request):
     user = request.user
     if not user.is_authenticated():
         return {}
-    return {'bundles': Bundle.objects.filter(owner = user)}
+    return {'bundles': Bundle.objects.filter(owner=user)}
 
 
 class PatchworkRequestContext(RequestContext):
-    def __init__(self, request, project = None,
-            dict = None, processors = None,
-            list_view = None, list_view_params = {}):
+
+    def __init__(self, request, project=None,
+                 dict=None, processors=None,
+                 list_view=None, list_view_params={}):
         self._project = project
         self.filters = Filters(request)
         if processors is None:
             processors = []
         processors.append(bundle)
-        super(PatchworkRequestContext, self). \
-                __init__(request, dict, processors);
+        super(PatchworkRequestContext, self).__init__(
+            request, dict, processors)
 
         self.update({
-                'filters': self.filters,
-                'messages': [],
-            })
+            'filters': self.filters,
+            'messages': [],
+        })
         if list_view:
             params = self.filters.params()
             for param in ['order', 'page']:
@@ -58,22 +60,22 @@  class PatchworkRequestContext(RequestContext):
 
                 value = data.get(param, None)
                 if value:
-                        params.append((param, value))
+                    params.append((param, value))
             self.update({
                 'list_view': {
-                        'view':         list_view,
-                        'view_params':  list_view_params,
-                        'params':       params
-                }})
+                        'view': list_view,
+                        'view_params': list_view_params,
+                        'params': params
+                        }})
 
         self.projects = Project.objects.all()
 
         self.update({
-                'project': self.project,
-                'site': Site.objects.get_current(),
-                'settings': settings,
-                'other_projects': len(self.projects) > 1
-            })
+            'project': self.project,
+            'site': Site.objects.get_current(),
+            'settings': settings,
+            'other_projects': len(self.projects) > 1
+        })
 
     def _set_project(self, project):
         self._project = project
diff --git a/patchwork/templatetags/listurl.py b/patchwork/templatetags/listurl.py
index 6dbdd74..a52f4fd 100644
--- a/patchwork/templatetags/listurl.py
+++ b/patchwork/templatetags/listurl.py
@@ -19,19 +19,19 @@ 
 
 from django import template
 from django.utils.html import escape
-from django.utils.safestring import mark_safe
 from django.utils.encoding import smart_str
 from patchwork.filters import filterclasses
 from django.conf import settings
 from django.core.urlresolvers import reverse, NoReverseMatch
-import re
 
 register = template.Library()
 
 # params to preserve across views
-list_params = [ c.param for c in filterclasses ] + ['order', 'page']
+list_params = [c.param for c in filterclasses] + ['order', 'page']
+
 
 class ListURLNode(template.defaulttags.URLNode):
+
     def __init__(self, kwargs):
         super(ListURLNode, self).__init__(None, [], {}, False)
         self.params = {}
@@ -41,8 +41,7 @@  class ListURLNode(template.defaulttags.URLNode):
 
     def render(self, context):
         view_name = template.Variable('list_view.view').resolve(context)
-        kwargs = template.Variable('list_view.view_params') \
-                      .resolve(context)
+        kwargs = template.Variable('list_view.view_params').resolve(context)
 
         str = None
         try:
@@ -51,10 +50,10 @@  class ListURLNode(template.defaulttags.URLNode):
             try:
                 project_name = settings.SETTINGS_MODULE.split('.')[0]
                 str = reverse(project_name + '.' + view_name,
-                               args=[], kwargs=kwargs)
+                              args=[], kwargs=kwargs)
             except NoReverseMatch:
                 raise
-        
+
         if str is None:
             return ''
 
@@ -66,13 +65,14 @@  class ListURLNode(template.defaulttags.URLNode):
             pass
 
         for (k, v) in self.params.iteritems():
-            params[smart_str(k,'ascii')] = v.resolve(context)
+            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()])
+        return str + '?' + '&'.join(
+            ['%s=%s' % (k, escape(v)) for (k, v) in params.iteritems()])
+
 
 @register.tag
 def listurl(parser, token):
diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py
index 57f289e..496dcfc 100644
--- a/patchwork/templatetags/patch.py
+++ b/patchwork/templatetags/patch.py
@@ -32,5 +32,5 @@  def patch_tags(patch):
         titles.append('%d %s' % (count, tag.name))
         counts.append(str(count))
     return mark_safe('<span title="%s">%s</span>' % (
-            ' / '.join(titles),
-            ' '.join(counts)))
+        ' / '.join(titles),
+        ' '.join(counts)))