From 80cbf2676f48ee38953c4a9f535098cf2a0eecac Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sat, 28 Jun 2014 18:21:44 +0200 Subject: [PATCH] drop Python 2.6 * no timedelta.total_seconds * no functools.total_ordering EOL. --- .travis.yml | 5 ----- docs/docs/install.rst | 2 +- isso/config.py | 3 +-- isso/queue/__init__.py | 3 +-- isso/tests/test_cache.py | 5 +---- isso/tests/test_comments.py | 5 +---- isso/tests/test_config.py | 6 +----- isso/tests/test_cors.py | 6 ++---- isso/tests/test_db.py | 5 +---- isso/tests/test_guard.py | 5 +---- isso/tests/test_html.py | 5 +---- isso/tests/test_migration.py | 6 +----- isso/tests/test_queue.py | 6 +----- isso/tests/test_utils.py | 6 +----- isso/tests/test_utils_hash.py | 5 +---- isso/tests/test_utils_types.py | 5 +---- isso/tests/test_vote.py | 7 ++----- isso/tests/test_wsgi.py | 6 +----- isso/utils/__init__.py | 5 ----- tox.ini | 13 ------------- 20 files changed, 19 insertions(+), 90 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a39e29..36254dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,10 @@ language: python python: 2.7 env: - - TOX_ENV=py26 - TOX_ENV=py27 - TOX_ENV=py33 - TOX_ENV=py34 - - TOX_ENV=squeeze - TOX_ENV=wheezy -matrix: - allow_failures: - - env: TOX_ENV=squeeze install: - pip install tox - sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm diff --git a/docs/docs/install.rst b/docs/docs/install.rst index bcbf951..e1edb3c 100644 --- a/docs/docs/install.rst +++ b/docs/docs/install.rst @@ -71,7 +71,7 @@ Install from PyPi Requirements: -- Python 2.6, 2.7 or 3.3+ (+ devel headers) +- Python 2.7, 3.3 or 3.4 (+ devel headers) - SQLite 3.3.8 or later - a working C compiler diff --git a/isso/config.py b/isso/config.py index fc032b4..4a4156f 100644 --- a/isso/config.py +++ b/isso/config.py @@ -9,7 +9,6 @@ import datetime from email.utils import parseaddr, formataddr from configparser import ConfigParser -from isso.utils import total_seconds from isso.compat import text_type as str logger = logging.getLogger("isso") @@ -91,7 +90,7 @@ class IssoParser(ConfigParser): except ValueError: return super(IssoParser, self).getint(section, key) else: - return int(total_seconds(delta)) + return int(delta.total_seconds()) def getlist(self, section, key): return list(map(str.strip, self.get(section, key).split(','))) diff --git a/isso/queue/__init__.py b/isso/queue/__init__.py index 2a903f8..67774e7 100644 --- a/isso/queue/__init__.py +++ b/isso/queue/__init__.py @@ -19,7 +19,6 @@ try: except ImportError: import Queue as queue -from isso.utils import total_seconds from isso.compat import iteritems logger = logging.getLogger("isso") @@ -98,7 +97,7 @@ class Queue(object): self.put(Queue.delay(msg, self.timeout)) def requeue(self, msg, timedelta): - self.put(Message(msg.type, msg.data, total_seconds(timedelta))) + self.put(Message(msg.type, msg.data, timedelta.total_seconds())) @property def size(self): diff --git a/isso/tests/test_cache.py b/isso/tests/test_cache.py index 85e468b..8e4ca9a 100644 --- a/isso/tests/test_cache.py +++ b/isso/tests/test_cache.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from isso.compat import text_type as str diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index d5c678b..fd4db0f 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -5,10 +5,7 @@ from __future__ import unicode_literals import os import json -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest try: from urllib.parse import urlencode diff --git a/isso/tests/test_config.py b/isso/tests/test_config.py index dc40e65..5b18256 100644 --- a/isso/tests/test_config.py +++ b/isso/tests/test_config.py @@ -1,11 +1,7 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - import io +import unittest from isso import config diff --git a/isso/tests/test_cors.py b/isso/tests/test_cors.py index 4cfc20d..0955ec3 100644 --- a/isso/tests/test_cors.py +++ b/isso/tests/test_cors.py @@ -1,10 +1,8 @@ +# -*- encoding: utf-8 -*- from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from werkzeug.test import Client from werkzeug.wrappers import Response diff --git a/isso/tests/test_db.py b/isso/tests/test_db.py index 08e1c7c..d25e8f5 100644 --- a/isso/tests/test_db.py +++ b/isso/tests/test_db.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from isso import config from isso.db import SQLite3, Adapter diff --git a/isso/tests/test_guard.py b/isso/tests/test_guard.py index 5096701..e7bbfbd 100644 --- a/isso/tests/test_guard.py +++ b/isso/tests/test_guard.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os import json diff --git a/isso/tests/test_html.py b/isso/tests/test_html.py index e60916e..7cba522 100644 --- a/isso/tests/test_html.py +++ b/isso/tests/test_html.py @@ -1,9 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from isso.utils import html diff --git a/isso/tests/test_migration.py b/isso/tests/test_migration.py index 6c1cf15..2d68c16 100644 --- a/isso/tests/test_migration.py +++ b/isso/tests/test_migration.py @@ -2,11 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest from os.path import join, dirname from isso import config diff --git a/isso/tests/test_queue.py b/isso/tests/test_queue.py index 0b0465f..8424e27 100644 --- a/isso/tests/test_queue.py +++ b/isso/tests/test_queue.py @@ -2,11 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest import datetime from isso.queue import Message, Queue, Full, Empty, Timeout diff --git a/isso/tests/test_utils.py b/isso/tests/test_utils.py index 88668f4..0504c15 100644 --- a/isso/tests/test_utils.py +++ b/isso/tests/test_utils.py @@ -1,10 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest from isso import utils from isso.utils import parse diff --git a/isso/tests/test_utils_hash.py b/isso/tests/test_utils_hash.py index 3094609..5b58079 100644 --- a/isso/tests/test_utils_hash.py +++ b/isso/tests/test_utils_hash.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from isso.compat import PY2K, string_types from isso.utils.hash import Hash, PBKDF2, new diff --git a/isso/tests/test_utils_types.py b/isso/tests/test_utils_types.py index 3619f2b..94924be 100644 --- a/isso/tests/test_utils_types.py +++ b/isso/tests/test_utils_types.py @@ -2,10 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from isso.compat import string_types from isso.utils import types diff --git a/isso/tests/test_vote.py b/isso/tests/test_vote.py index 4b18483..0a6495f 100644 --- a/isso/tests/test_vote.py +++ b/isso/tests/test_vote.py @@ -1,14 +1,11 @@ +# -*- encoding: utf-8 -*- from __future__ import unicode_literals +import unittest import os import json -try: - import unittest2 as unittest -except ImportError: - import unittest - from werkzeug.wrappers import Response from isso import Isso, config, dist diff --git a/isso/tests/test_wsgi.py b/isso/tests/test_wsgi.py index 17e0b12..254b51e 100644 --- a/isso/tests/test_wsgi.py +++ b/isso/tests/test_wsgi.py @@ -1,10 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest from isso import wsgi diff --git a/isso/utils/__init__.py b/isso/utils/__init__.py index bee0b01..dfc361c 100644 --- a/isso/utils/__init__.py +++ b/isso/utils/__init__.py @@ -17,11 +17,6 @@ except ImportError: import ipaddr as ipaddress -# Python 2.6 compatibility -def total_seconds(td): - return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 - - def anonymize(remote_addr): """ Anonymize IPv4 and IPv6 :param remote_addr: to /24 (zero'd) diff --git a/tox.ini b/tox.ini index 6d64448..e888f12 100755 --- a/tox.ini +++ b/tox.ini @@ -7,13 +7,6 @@ deps = commands = python setup.py nosetests -[testenv:py26] -deps = - argparse - unittest2 - configparser - {[testenv]deps} - [testenv:py27] deps = configparser @@ -28,12 +21,6 @@ deps= passlib==1.5.3 werkzeug==0.8.3 -[testenv:squeeze] -basepython=python2.6 -deps= - {[testenv:py26]deps} - {[testenv:debian]deps} - [testenv:wheezy] basepython=python2.7 deps =