[PATCH 1/2] trivial: Remove additional Django < 1.8 code

Stephen Finucane stephen at that.guru
Tue Apr 10 02:37:15 AEST 2018


Yet more stuff that was missed in the previous changes.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/management/commands/parsearchive.py | 26 ++++---------
 patchwork/management/commands/parsemail.py    | 33 ++++++----------
 patchwork/settings/dev.py                     | 56 +++++++++++----------------
 patchwork/settings/production.example.py      |  7 +---
 4 files changed, 44 insertions(+), 78 deletions(-)

diff --git a/patchwork/management/commands/parsearchive.py b/patchwork/management/commands/parsearchive.py
index f5ea4af4..16ca80f6 100644
--- a/patchwork/management/commands/parsearchive.py
+++ b/patchwork/management/commands/parsearchive.py
@@ -19,7 +19,6 @@
 
 import logging
 import mailbox
-from optparse import make_option
 import os
 import sys
 
@@ -35,23 +34,14 @@ logger = logging.getLogger(__name__)
 class Command(BaseCommand):
     help = 'Parse an mbox archive file and store any patches/comments found.'
 
-    if django.VERSION < (1, 8):
-        args = '<infile>'
-        option_list = BaseCommand.option_list + (
-            make_option(
-                '--list-id',
-                help='mailing list ID. If not supplied, this will be '
-                'extracted from the mail headers.'),
-        )
-    else:
-        def add_arguments(self, parser):
-            parser.add_argument(
-                'infile',
-                help='input mbox filename')
-            parser.add_argument(
-                '--list-id',
-                help='mailing list ID. If not supplied, this will be '
-                'extracted from the mail headers.')
+    def add_arguments(self, parser):
+        parser.add_argument(
+            'infile',
+            help='input mbox filename')
+        parser.add_argument(
+            '--list-id',
+            help='mailing list ID. If not supplied, this will be '
+            'extracted from the mail headers.')
 
     def handle(self, *args, **options):
         results = {
diff --git a/patchwork/management/commands/parsemail.py b/patchwork/management/commands/parsemail.py
index 52ec8bc5..6d9825f7 100644
--- a/patchwork/management/commands/parsemail.py
+++ b/patchwork/management/commands/parsemail.py
@@ -19,10 +19,8 @@
 
 import email
 import logging
-from optparse import make_option
 import sys
 
-import django
 from django.core.management import base
 from django.utils import six
 
@@ -34,26 +32,17 @@ logger = logging.getLogger(__name__)
 class Command(base.BaseCommand):
     help = 'Parse an mbox file and store any patch/comment found.'
 
-    if django.VERSION < (1, 8):
-        args = '<infile>'
-        option_list = base.BaseCommand.option_list + (
-            make_option(
-                '--list-id',
-                help='mailing list ID. If not supplied, this will be '
-                'extracted from the mail headers.'),
-        )
-    else:
-        def add_arguments(self, parser):
-            parser.add_argument(
-                'infile',
-                nargs='?',
-                type=str,
-                default=None,
-                help='input mbox file (a filename or stdin)')
-            parser.add_argument(
-                '--list-id',
-                help='mailing list ID. If not supplied, this will be '
-                'extracted from the mail headers.')
+    def add_arguments(self, parser):
+        parser.add_argument(
+            'infile',
+            nargs='?',
+            type=str,
+            default=None,
+            help='input mbox file (a filename or stdin)')
+        parser.add_argument(
+            '--list-id',
+            help='mailing list ID. If not supplied, this will be '
+            'extracted from the mail headers.')
 
     def handle(self, *args, **options):
         infile = args[0] if args else options['infile']
diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py
index 26d3e830..1f686f42 100644
--- a/patchwork/settings/dev.py
+++ b/patchwork/settings/dev.py
@@ -25,11 +25,6 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000000'  # noqa
 
 DEBUG = True
 
-if django.VERSION < (1, 8):
-    # In Django 1.8+, this is only necessary if the value differs from
-    # the value for 'DEBUG'
-    TEMPLATE_DEBUG = True
-
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.mysql',
@@ -38,19 +33,15 @@ DATABASES = {
         'USER': os.getenv('PW_TEST_DB_USER', 'patchwork'),
         'PASSWORD': os.getenv('PW_TEST_DB_PASS', 'password'),
         'NAME': os.getenv('PW_TEST_DB_NAME', 'patchwork'),
+        'TEST': {
+            'CHARSET': 'utf8',
+        },
     },
 }
 
 if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres':
     DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
 
-if django.VERSION >= (1, 7):
-    DATABASES['default']['TEST'] = {
-        'CHARSET': 'utf8',
-    }
-else:
-    DATABASES['default']['TEST_CHARSET'] = 'utf8'
-
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 
 #
@@ -68,27 +59,26 @@ PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
 
 # django-debug-toolbar
 
-if django.VERSION >= (1, 8):
-    INSTALLED_APPS += [
-        'debug_toolbar'
-    ]
-
-    DEBUG_TOOLBAR_PATCH_SETTINGS = False
-
-    # This should go first in the middleware classes
-    if django.VERSION >= (1, 10):
-        MIDDLEWARE = [
-            'debug_toolbar.middleware.DebugToolbarMiddleware',
-        ] + MIDDLEWARE
-    else:
-        MIDDLEWARE_CLASSES = [
-            'debug_toolbar.middleware.DebugToolbarMiddleware',
-        ] + MIDDLEWARE_CLASSES
-
-    INTERNAL_IPS = [
-        '127.0.0.1', '::1',
-        '172.17.0.1'
-    ]
+INSTALLED_APPS += [
+    'debug_toolbar'
+]
+
+DEBUG_TOOLBAR_PATCH_SETTINGS = False
+
+# This should go first in the middleware classes
+if django.VERSION >= (1, 10):
+    MIDDLEWARE = [
+        'debug_toolbar.middleware.DebugToolbarMiddleware',
+    ] + MIDDLEWARE
+else:
+    MIDDLEWARE_CLASSES = [
+        'debug_toolbar.middleware.DebugToolbarMiddleware',
+    ] + MIDDLEWARE_CLASSES
+
+INTERNAL_IPS = [
+    '127.0.0.1', '::1',
+    '172.17.0.1'
+]
 
 
 #
diff --git a/patchwork/settings/production.example.py b/patchwork/settings/production.example.py
index 03a0fb0a..e97ba578 100644
--- a/patchwork/settings/production.example.py
+++ b/patchwork/settings/production.example.py
@@ -11,8 +11,6 @@ from __future__ import absolute_import
 
 import os
 
-import django
-
 from .base import *  # noqa
 
 #
@@ -74,6 +72,5 @@ DATABASES = {
 
 STATIC_ROOT = os.environ.get('STATIC_ROOT', '/srv/patchwork/htdocs/static')
 
-if django.VERSION >= (1, 7):
-    STATICFILES_STORAGE = \
-        'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
+STATICFILES_STORAGE = (
+    'django.contrib.staticfiles.storage.ManifestStaticFilesStorage')
-- 
2.14.3



More information about the Patchwork mailing list