From: Stephen Finucane Date: Thu, 26 Nov 2015 18:24:59 +0000 (+0000) Subject: py3: Add required 'future' imports X-Git-Tag: v1.1.0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cb7c6c52ed0523de59178755057b9a1ae6dcce2;p=thirdparty%2Fpatchwork.git py3: Add required 'future' imports 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 --- diff --git a/patchwork/admin.py b/patchwork/admin.py index d32edbab..4723a4ba 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 94d898a9..5ded8ef8 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 513daef0..866743f9 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 2da5d23e..44f0d0a3 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 db671ffc..bb752fb8 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 03279588..b2d12366 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 286372f9..a409e89e 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 13b4466a..a63efed4 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 8ad60495..413af4d9 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 b4c0e589..c70d893e 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 9cf6712e..6aaa4da9 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 a52f4fdb..9e6e9f11 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 af5e54dd..79cc9233 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 c337c744..b5756892 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 abdbb4dc..bf90b87a 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 a9ee8dd5..2a877d07 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 f440e3ee..44cfc920 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 5ce87136..ddbbb7cb 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 d69cb210..62ae00f5 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 ffae91a1..b0b4e885 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 9d90f566..9f210125 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 3fb47e2f..48d7c67e 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 aebba34c..46c87683 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 62ff8531..30aeef2c 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 114dbe07..024799eb 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 126ecc95..97d15a7e 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 6bdfe567..3b0be9fa 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