[PATCH 3/9] py3: Add required 'future' imports

Stephen Finucane stephen.finucane at intel.com
Mon Nov 30 09:10:44 AEDT 2015


These are quite limited as patchwork only supports Python 2.6+. As
such, only the 'print_function' and 'absolute_import' statements are
required.

Found using 'modernize'

Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
 patchwork/admin.py                       | 2 ++
 patchwork/bin/parsearchive.py            | 4 +++-
 patchwork/bin/parsemail.py               | 2 ++
 patchwork/bin/update-patchwork-status.py | 6 +++---
 patchwork/filters.py                     | 2 ++
 patchwork/forms.py                       | 1 +
 patchwork/paginator.py                   | 1 +
 patchwork/parser.py                      | 8 +++++---
 patchwork/requestcontext.py              | 2 ++
 patchwork/settings/dev.py                | 4 +++-
 patchwork/settings/production.example.py | 4 +++-
 patchwork/templatetags/listurl.py        | 2 ++
 patchwork/templatetags/patch.py          | 2 ++
 patchwork/templatetags/person.py         | 2 ++
 patchwork/templatetags/syntax.py         | 2 ++
 patchwork/tests/test_bundles.py          | 2 ++
 patchwork/tests/test_list.py             | 2 ++
 patchwork/tests/test_person.py           | 2 ++
 patchwork/utils.py                       | 1 +
 patchwork/views/__init__.py              | 3 ++-
 patchwork/views/base.py                  | 2 ++
 patchwork/views/bundle.py                | 2 ++
 patchwork/views/mail.py                  | 2 ++
 patchwork/views/patch.py                 | 1 +
 patchwork/views/project.py               | 1 +
 patchwork/views/user.py                  | 1 +
 patchwork/views/xmlrpc.py                | 2 ++
 27 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/patchwork/admin.py b/patchwork/admin.py
index d32edba..4723a4b 100644
--- a/patchwork/admin.py
+++ b/patchwork/admin.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django.contrib import admin
 
 from patchwork.models import (
diff --git a/patchwork/bin/parsearchive.py b/patchwork/bin/parsearchive.py
index 94d898a..5ded8ef 100755
--- a/patchwork/bin/parsearchive.py
+++ b/patchwork/bin/parsearchive.py
@@ -21,13 +21,15 @@
 
 """Utility to parse an mbox archive file."""
 
+from __future__ import absolute_import
+
 import argparse
 import logging
 import mailbox
 
 import django
 
-import parsemail
+from . import parsemail
 
 VERBOSITY_LEVELS = {
     'debug': logging.DEBUG,
diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
index 513daef..866743f 100755
--- a/patchwork/bin/parsemail.py
+++ b/patchwork/bin/parsemail.py
@@ -19,6 +19,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 import argparse
 import codecs
 import datetime
diff --git a/patchwork/bin/update-patchwork-status.py b/patchwork/bin/update-patchwork-status.py
index 2da5d23..44f0d0a 100755
--- a/patchwork/bin/update-patchwork-status.py
+++ b/patchwork/bin/update-patchwork-status.py
@@ -19,6 +19,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import print_function
 
 import sys
 import subprocess
@@ -60,11 +61,10 @@ def main(args):
     revs = commits(options, revspec)
 
     for rev in revs:
-        print rev
-        print commit(options, rev)
+        print(rev)
+        print(commit(options, rev))
 
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
 
-
diff --git a/patchwork/filters.py b/patchwork/filters.py
index db671ff..bb752fb 100644
--- a/patchwork/filters.py
+++ b/patchwork/filters.py
@@ -18,6 +18,8 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
+from __future__ import absolute_import
+
 from patchwork.models import Person, State
 from django.utils.safestring import mark_safe
 from django.utils.html import escape
diff --git a/patchwork/forms.py b/patchwork/forms.py
index 0327958..b2d1236 100644
--- a/patchwork/forms.py
+++ b/patchwork/forms.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 from django.contrib.auth.models import User
 from django import forms
diff --git a/patchwork/paginator.py b/patchwork/paginator.py
index 286372f..a409e89 100644
--- a/patchwork/paginator.py
+++ b/patchwork/paginator.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 from django.core import paginator
 from django.conf import settings
diff --git a/patchwork/parser.py b/patchwork/parser.py
index 13b4466..a63efed 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -19,6 +19,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+from __future__ import print_function
 
 import hashlib
 import re
@@ -257,13 +259,13 @@ def main(args):
     (patch, comment) = parse_patch(content)
 
     if options.print_hash and patch:
-        print hash_patch(patch).hexdigest()
+        print(hash_patch(patch).hexdigest())
 
     if options.print_patch and patch:
-        print "Patch: ------\n" + patch
+        print("Patch: ------\n" + patch)
 
     if options.print_comment and comment:
-        print "Comment: ----\n" + comment
+        print("Comment: ----\n" + comment)
 
 if __name__ == '__main__':
     import sys
diff --git a/patchwork/requestcontext.py b/patchwork/requestcontext.py
index 8ad6049..413af4d 100644
--- a/patchwork/requestcontext.py
+++ b/patchwork/requestcontext.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django.template import RequestContext
 from django.utils.html import escape
 from django.contrib.sites.models import Site
diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py
index b4c0e58..c70d893 100644
--- a/patchwork/settings/dev.py
+++ b/patchwork/settings/dev.py
@@ -7,9 +7,11 @@ Design based on:
     http://www.revsys.com/blog/2014/nov/21/recommended-django-project-layout/
 """
 
+from __future__ import absolute_import
+
 import django
 
-from base import *
+from .base import *
 
 #
 # Core settings
diff --git a/patchwork/settings/production.example.py b/patchwork/settings/production.example.py
index 9cf6712..6aaa4da 100644
--- a/patchwork/settings/production.example.py
+++ b/patchwork/settings/production.example.py
@@ -7,7 +7,9 @@ Design based on:
     http://www.revsys.com/blog/2014/nov/21/recommended-django-project-layout/
 """
 
-from base import *
+from __future__ import absolute_import
+
+from .base import *
 
 #
 # Core settings
diff --git a/patchwork/templatetags/listurl.py b/patchwork/templatetags/listurl.py
index a52f4fd..9e6e9f1 100644
--- a/patchwork/templatetags/listurl.py
+++ b/patchwork/templatetags/listurl.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django import template
 from django.utils.html import escape
 from django.utils.encoding import smart_str
diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py
index af5e54d..79cc923 100644
--- a/patchwork/templatetags/patch.py
+++ b/patchwork/templatetags/patch.py
@@ -18,6 +18,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django import template
 from django.utils.safestring import mark_safe
 
diff --git a/patchwork/templatetags/person.py b/patchwork/templatetags/person.py
index c337c74..b575689 100644
--- a/patchwork/templatetags/person.py
+++ b/patchwork/templatetags/person.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django import template
 from django.utils.html import escape
 from django.utils.safestring import mark_safe
diff --git a/patchwork/templatetags/syntax.py b/patchwork/templatetags/syntax.py
index abdbb4d..bf90b87 100644
--- a/patchwork/templatetags/syntax.py
+++ b/patchwork/templatetags/syntax.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django import template
 from django.utils.html import escape
 from django.utils.safestring import mark_safe
diff --git a/patchwork/tests/test_bundles.py b/patchwork/tests/test_bundles.py
index a9ee8dd..2a877d0 100644
--- a/patchwork/tests/test_bundles.py
+++ b/patchwork/tests/test_bundles.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 import unittest
 import datetime
 from django.test import TestCase
diff --git a/patchwork/tests/test_list.py b/patchwork/tests/test_list.py
index f440e3e..44cfc92 100644
--- a/patchwork/tests/test_list.py
+++ b/patchwork/tests/test_list.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 import unittest
 import random
 import datetime
diff --git a/patchwork/tests/test_person.py b/patchwork/tests/test_person.py
index 5ce8713..ddbbb7c 100644
--- a/patchwork/tests/test_person.py
+++ b/patchwork/tests/test_person.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 import unittest
 from django.test import TestCase
 from django.test.client import Client
diff --git a/patchwork/utils.py b/patchwork/utils.py
index d69cb21..62ae00f 100644
--- a/patchwork/utils.py
+++ b/patchwork/utils.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 import itertools
 import datetime
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py
index ffae91a..b0b4e88 100644
--- a/patchwork/views/__init__.py
+++ b/patchwork/views/__init__.py
@@ -17,8 +17,9 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
-from base import *
+from .base import *
 from patchwork.utils import Order, get_patch_ids, bundle_actions, set_bundle
 from patchwork.paginator import Paginator
 from patchwork.forms import MultiplePatchForm
diff --git a/patchwork/views/base.py b/patchwork/views/base.py
index 9d90f56..9f21012 100644
--- a/patchwork/views/base.py
+++ b/patchwork/views/base.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 import json
 
 from patchwork.models import Patch, Project, Person, EmailConfirmation
diff --git a/patchwork/views/bundle.py b/patchwork/views/bundle.py
index 3fb47e2..48d7c67 100644
--- a/patchwork/views/bundle.py
+++ b/patchwork/views/bundle.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.models import User
 from django.shortcuts import render_to_response, get_object_or_404
diff --git a/patchwork/views/mail.py b/patchwork/views/mail.py
index aebba34..46c8768 100644
--- a/patchwork/views/mail.py
+++ b/patchwork/views/mail.py
@@ -17,6 +17,8 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
+
 from patchwork.requestcontext import PatchworkRequestContext
 from patchwork.models import EmailOptout, EmailConfirmation
 from patchwork.forms import OptinoutRequestForm, EmailForm
diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py
index 62ff853..30aeef2 100644
--- a/patchwork/views/patch.py
+++ b/patchwork/views/patch.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 from patchwork.models import Patch, Project, Bundle
 from patchwork.forms import PatchForm, CreateBundleForm
diff --git a/patchwork/views/project.py b/patchwork/views/project.py
index 114dbe0..024799e 100644
--- a/patchwork/views/project.py
+++ b/patchwork/views/project.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 from patchwork.models import Patch, Project
 from django.shortcuts import render_to_response, get_object_or_404
diff --git a/patchwork/views/user.py b/patchwork/views/user.py
index 126ecc9..97d15a7 100644
--- a/patchwork/views/user.py
+++ b/patchwork/views/user.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+from __future__ import absolute_import
 
 from django.contrib.auth.decorators import login_required
 from patchwork.requestcontext import PatchworkRequestContext
diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
index 6bdfe56..3b0be9f 100644
--- a/patchwork/views/xmlrpc.py
+++ b/patchwork/views/xmlrpc.py
@@ -20,6 +20,8 @@
 # Patchwork XMLRPC interface
 #
 
+from __future__ import absolute_import
+
 from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
 from DocXMLRPCServer import XMLRPCDocGenerator
 import base64
-- 
2.0.0



More information about the Patchwork mailing list