diff --git a/.travis.yml b/.travis.yml index f4246bb..0302d5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,26 @@ language: python matrix: - allow_failures: - - env: TOX_ENV=squeeze include: - - python: 2.6 - env: TOX_ENV=py26 - python: 2.7 env: TOX_ENV=py27 - - python: 3.3 - env: TOX_ENV=py33 - python: 3.4 env: TOX_ENV=py34 - python: 3.5 env: TOX_ENV=py35 - python: 3.6 env: TOX_ENV=py36 - - python: 2.6 - env: TOX_ENV=squeeze - python: 2.7 env: TOX_ENV=wheezy install: - pip install -U pip - - pip install tox - - pip install pyflakes + - pip install flake8 tox - sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm script: - tox -e $TOX_ENV - - python -m pyflakes.__main__ $(git ls-files | grep -E "^isso/.+.py$" | grep -v "^isso/compat.py") + # stop the build if there are Python syntax errors or undefined names + - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics notifications: irc: channels: diff --git a/docs/docs/install.rst b/docs/docs/install.rst index 688b050..8ce4f8c 100644 --- a/docs/docs/install.rst +++ b/docs/docs/install.rst @@ -79,7 +79,7 @@ Install from PyPi Requirements ^^^^^^^^^^^^ -- Python 2.6, 2.7 or 3.3+ (+ devel headers) +- Python 2.7 or 3.4+ (+ devel headers) - SQLite 3.3.8 or later - a working C compiler @@ -157,7 +157,7 @@ Install from Source If you want to hack on Isso or track down issues, there's an alternate way to set up Isso. It requires a lot more dependencies and effort: -- Python 2.6, 2.7 or 3.3+ (+ devel headers) +- Python 2.7 or 3.4+ (+ devel headers) - Virtualenv - SQLite 3.3.8 or later - a working C compiler diff --git a/isso/compat.py b/isso/compat.py index e12f268..e38ecc5 100644 --- a/isso/compat.py +++ b/isso/compat.py @@ -1,28 +1,22 @@ # -*- encoding: utf-8 -*- -import sys -PY2K = sys.version_info[0] == 2 - -if not PY2K: - - map, zip, filter = map, zip, filter - from functools import reduce - - iteritems = lambda dikt: iter(dikt.items()) - +try: + text_type = unicode # Python 2 + string_types = (str, unicode) + PY2K = True +except NameError: # Python 3 + PY2K = False text_type = str string_types = (str, ) +if not PY2K: buffer = memoryview + filter, map, zip = filter, map, zip + iteritems = lambda dikt: iter(dikt.items()) # noqa: E731 + from functools import reduce else: - - from itertools import imap, izip, ifilter - map, zip, filter = imap, izip, ifilter - reduce = reduce - - iteritems = lambda dikt: dikt.iteritems() - - text_type = unicode - string_types = (str, unicode) - buffer = buffer + from itertools import ifilter, imap, izip + filter, map, zip = ifilter, imap, izip + iteritems = lambda dikt: dikt.iteritems() # noqa: E731 + reduce = reduce diff --git a/isso/config.py b/isso/config.py index 234a0fe..c2a05ce 100644 --- a/isso/config.py +++ b/isso/config.py @@ -17,11 +17,6 @@ from isso.compat import text_type as str logger = logging.getLogger("isso") -# Python 2.6 compatibility -def total_seconds(td): - return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 - - def timedelta(string): """ Parse :param string: into :class:`datetime.timedelta`, you can use any @@ -101,7 +96,7 @@ class IssoParser(ConfigParser): try: return int(delta.total_seconds()) except AttributeError: - 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/tests/test_comments.py b/isso/tests/test_comments.py index 1e2bdf1..e7bc011 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -5,11 +5,7 @@ from __future__ import unicode_literals import os import json import tempfile - -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..2fd1b4d 100644 --- a/isso/tests/test_config.py +++ b/isso/tests/test_config.py @@ -1,10 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest import io from isso import config diff --git a/isso/tests/test_cors.py b/isso/tests/test_cors.py index 4cfc20d..415ea51 100644 --- a/isso/tests/test_cors.py +++ b/isso/tests/test_cors.py @@ -1,10 +1,7 @@ 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 54b9122..74e0831 100644 --- a/isso/tests/test_db.py +++ b/isso/tests/test_db.py @@ -1,10 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest import os import sqlite3 import tempfile diff --git a/isso/tests/test_guard.py b/isso/tests/test_guard.py index fca932c..a9ae365 100644 --- a/isso/tests/test_guard.py +++ b/isso/tests/test_guard.py @@ -2,11 +2,7 @@ from __future__ import unicode_literals -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest import os import json import tempfile diff --git a/isso/tests/test_html.py b/isso/tests/test_html.py index b1be6dc..362e239 100644 --- a/isso/tests/test_html.py +++ b/isso/tests/test_html.py @@ -1,10 +1,6 @@ # -*- encoding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - +import unittest import textwrap from isso import config diff --git a/isso/tests/test_migration.py b/isso/tests/test_migration.py index 7b73d75..8a876ee 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 import tempfile from os.path import join, dirname 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 626d75e..18a790e 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 import config @@ -70,4 +67,4 @@ class TestCreate(unittest.TestCase): pbkdf2 = _new("pbkdf2:16:2:md5") self.assertIsInstance(pbkdf2, PBKDF2) self.assertEqual(pbkdf2.dklen, 2) - self.assertEqual(pbkdf2.func, "md5") \ No newline at end of file + self.assertEqual(pbkdf2.func, "md5") diff --git a/isso/tests/test_vote.py b/isso/tests/test_vote.py index f6817a0..4045ccb 100644 --- a/isso/tests/test_vote.py +++ b/isso/tests/test_vote.py @@ -4,11 +4,7 @@ from __future__ import unicode_literals import os import json import tempfile - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from werkzeug.wrappers import Response 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/setup.py b/setup.py index b2c7482..ef866fe 100644 --- a/setup.py +++ b/setup.py @@ -5,10 +5,13 @@ import sys from setuptools import setup, find_packages -requires = ['itsdangerous', 'misaka>=1.0,<2.0', 'html5lib==0.9999999', 'Jinja2'] +requires = ['html5lib==0.9999999', 'itsdangerous', 'Jinja2', + 'misaka>=1.0,<2.0', 'werkzeug>=0.9'] -if (3, 0) <= sys.version_info < (3, 3): - raise SystemExit("Python 3.0, 3.1 and 3.2 are not supported") +if sys.version_info < (2, 7): + raise SystemExit("Python 2 versions < 2.7 are not supported.") +elif (3, 0) <= sys.version_info < (3, 4): + raise SystemExit("Python 3 versions < 3.4 are not supported.") setup( name='isso', @@ -27,16 +30,14 @@ setup( "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4" + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6" ], install_requires=requires, extras_require={ - ':python_version=="2.6"': ['argparse', 'ordereddict'], - ':python_version=="2.6" or python_version=="2.7"': ['ipaddr>=2.1', 'configparser', 'werkzeug>=0.8'], - ':python_version!="2.6" and python_version!="2.7"': ['werkzeug>=0.9'] + ':python_version=="2.7"': ['ipaddr>=2.1', 'configparser'] }, entry_points={ 'console_scripts': diff --git a/tox.ini b/tox.ini index 5b8b90a..bb55662 100755 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,py35,py36 +envlist = py27,py34,py35,py36 [testenv] deps = @@ -8,14 +8,6 @@ deps = commands = python setup.py nosetests -[testenv:py26] -deps = - argparse - unittest2 - ordereddict - configparser - {[testenv]deps} - [testenv:py27] deps = configparser @@ -30,12 +22,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 =