Skip to content

Commit

Permalink
Add python 2.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Nov 14, 2015
1 parent 3b4c467 commit 4dcc48a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
# - 3.5 (pylint currently fails with python 3.5)
- 3.5
# - pypy (something doesn't work with regex module)
install:
- pip install pip --upgrade
- pip install -r dev-requirements.txt
- pip install pytest --upgrade
- pip install pytest-benchmark
- pip install pylint
- pip install coveralls
script:
- pylint guessit
- if [ $TRAVIS_PYTHON_VERSION != 2.6 ] && [ $TRAVIS_PYTHON_VERSION != 3.5 ]; then pylint rebulk; fi
- coverage run --source=guessit setup.py test
- python setup.py build
after_success:
Expand Down
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ History
2.0b2 (unreleased)
------------------

- Nothing changed yet.
- Add python 2.6 support.


2.0b1 (2015-11-11)
Expand Down
5 changes: 4 additions & 1 deletion guessit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
API functions that can be used by external software
"""
from __future__ import unicode_literals
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError: # pragma: no-cover
from ordereddict import OrderedDict # pylint:disable=import-error

import six

Expand Down
27 changes: 27 additions & 0 deletions guessit/backports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Backports
"""
# pragma: no-cover
# pylint: disabled

def cmp_to_key(mycmp):
"""functools.cmp_to_key backport"""
class KeyClass(object):
"""Key class"""
def __init__(self, obj, *args): # pylint: disable=unused-argument
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
return mycmp(self.obj, other.obj) > 0
def __eq__(self, other):
return mycmp(self.obj, other.obj) == 0
def __le__(self, other):
return mycmp(self.obj, other.obj) <= 0
def __ge__(self, other):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
return KeyClass
5 changes: 4 additions & 1 deletion guessit/jsonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"""
JSON Utils
"""
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError: # pragma: no-cover
from ordereddict import OrderedDict # pylint:disable=import-error
import json

from rebulk.match import Match
Expand Down
5 changes: 4 additions & 1 deletion guessit/rules/common/comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"""
from __future__ import unicode_literals

from functools import cmp_to_key
try:
from functools import cmp_to_key
except ImportError:
from ...backports import cmp_to_key


def marker_comparator_predicate(match):
Expand Down
5 changes: 4 additions & 1 deletion guessit/yamlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"""
Options
"""
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError: # pragma: no-cover
from ordereddict import OrderedDict # pylint:disable=import-error
import babelfish

import yaml
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand

import sys
import os


here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
HISTORY = open(os.path.join(here, 'HISTORY.rst')).read()

install_requires = ['rebulk>=0.6.1', 'regex', 'babelfish>=0.5.5', 'python-dateutil']

install_requires = ['rebulk>=0.6.2', 'regex', 'babelfish>=0.5.5', 'python-dateutil']
if sys.version_info < (2, 7):
install_requires.extend(['argparse', 'ordereddict'])
setup_requires = ['pytest-runner']

tests_require = ['pytest', 'pytest-benchmark', 'PyYAML']
Expand Down
14 changes: 12 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
[tox]
envlist = py27,py33,py34,py35,pypy
envlist = py26,py27,py33,py34,py35,pypy

[testenv:py26]
commands =
{envbindir}/pip install -r dev-requirements.txt
{envpython} setup.py test

[testenv:py35]
commands =
{envbindir}/pip install -r dev-requirements.txt
{envpython} setup.py test

[testenv]
commands =
{envbindir}/pip install -r dev-requirements.txt
{envbindir}/pylint guessit
{envpython} setup.py test -a "--doctest-modules --doctest-glob='README.rst'"
{envpython} setup.py test

[pep8]
max-line-length = 119

0 comments on commit 4dcc48a

Please sign in to comment.