@@ -26,13 +26,8 @@ import time
import operator
import codecs
from email import message_from_file
-try:
- from email.header import Header, decode_header
- from email.utils import parsedate_tz, mktime_tz
-except ImportError:
- # Python 2.4 compatibility
- from email.Header import Header, decode_header
- from email.Utils import parsedate_tz, mktime_tz
+from email.header import Header, decode_header
+from email.utils import parsedate_tz, mktime_tz
from patchwork.parser import parse_patch
from patchwork.models import Patch, Project, Person, Comment, State, \
@@ -20,16 +20,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import hashlib
import re
from collections import Counter
-try:
- import hashlib
- sha1_hash = hashlib.sha1
-except ImportError:
- import sha
- sha1_hash = sha.sha
-
_hunk_re = re.compile('^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@')
_filename_re = re.compile('^(---|\+\+\+) (\S+)')
@@ -194,7 +188,7 @@ def hash_patch(str):
str = str.strip() + '\n'
prefixes = ['-', '+', ' ']
- hash = sha1_hash()
+ hash = hashlib.sha1()
for line in str.split('\n'):
@@ -25,11 +25,7 @@ from patchwork.models import Project, Person, Patch, Comment, State, \
from patchwork.tests.utils import read_patch, read_mail, create_email, \
defaults, create_user
-try:
- from email.mime.text import MIMEText
-except ImportError:
- # Python 2.4 compatibility
- from email.MIMEText import MIMEText
+from email.mime.text import MIMEText
class PatchTest(TestCase):
fixtures = ['default_states']
@@ -24,13 +24,8 @@ from django.contrib.auth.models import User
from django.forms.fields import EmailField
from email import message_from_file
-try:
- from email.mime.text import MIMEText
- from email.mime.multipart import MIMEMultipart
-except ImportError:
- # Python 2.4 compatibility
- from email.MIMEText import MIMEText
- from email.MIMEMultipart import MIMEMultipart
+from email.mime.text import MIMEText
+from email.mime.multipart import MIMEMultipart
# helper functions for tests
_test_mail_dir = os.path.join(os.path.dirname(__file__), 'mail')
@@ -26,20 +26,11 @@ from patchwork.models import Comment
import re
import datetime
-try:
- from email.mime.nonmultipart import MIMENonMultipart
- from email.encoders import encode_7or8bit
- from email.parser import HeaderParser
- from email.header import Header
- import email.utils
-except ImportError:
- # Python 2.4 compatibility
- from email.MIMENonMultipart import MIMENonMultipart
- from email.Encoders import encode_7or8bit
- from email.Parser import HeaderParser
- from email.Header import Header
- import email.Utils
- email.utils = email.Utils
+from email.mime.nonmultipart import MIMENonMultipart
+from email.encoders import encode_7or8bit
+from email.parser import HeaderParser
+from email.header import Header
+import email.utils
def generic_list(request, project, view,
view_args = {}, filter_settings = [], patches = None,
@@ -22,7 +22,7 @@
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
from django.http import HttpResponse, HttpResponseRedirect, \
- HttpResponseServerError
+ HttpResponseServerError
from django.core import urlresolvers
from django.contrib.auth import authenticate
from patchwork.models import Patch, Project, Person, State
@@ -34,18 +34,15 @@ import base64
import xmlrpclib
class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
+
def __init__(self):
- if sys.version_info[:3] >= (2,5,):
- SimpleXMLRPCDispatcher.__init__(self, allow_none=False,
- encoding=None)
- def _dumps(obj, *args, **kwargs):
- kwargs['allow_none'] = self.allow_none
- kwargs['encoding'] = self.encoding
- return xmlrpclib.dumps(obj, *args, **kwargs)
- else:
- def _dumps(obj, *args, **kwargs):
- return xmlrpclib.dumps(obj, *args, **kwargs)
- SimpleXMLRPCDispatcher.__init__(self)
+ SimpleXMLRPCDispatcher.__init__(self, allow_none=False,
+ encoding=None)
+
+ def _dumps(obj, *args, **kwargs):
+ kwargs['allow_none'] = self.allow_none
+ kwargs['encoding'] = self.encoding
+ return xmlrpclib.dumps(obj, *args, **kwargs)
self.dumps = _dumps
None of the supported versions of Django (currently 1.6 -> 1.8) support Python < 2.6. There is no need to keep code for older versions of Python around. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com> --- patchwork/bin/parsemail.py | 9 ++------- patchwork/parser.py | 10 ++-------- patchwork/tests/test_patchparser.py | 6 +----- patchwork/tests/utils.py | 9 ++------- patchwork/views/__init__.py | 19 +++++-------------- patchwork/views/xmlrpc.py | 21 +++++++++------------ 6 files changed, 21 insertions(+), 53 deletions(-)