diff --git a/CHANGES.rst b/CHANGES.rst index 0f779db..a06e85d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,12 @@ Changelog Here you can see the full list of changes between each SQLAlchemy-Utils release. +0.17.1 (2013-10-23) +^^^^^^^^^^^^^^^^^^^ + +- Removed compat module, added total_ordering package to Python 2.6 requirements + + 0.17.0 (2013-10-23) ^^^^^^^^^^^^^^^^^^^ diff --git a/setup.py b/setup.py index d6b4d1f..5b5c336 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ for name, requirements in extras_require.items(): setup( name='SQLAlchemy-Utils', - version='0.17.0', + version='0.17.1', url='https://github.com/kvesteri/sqlalchemy-utils', license='BSD', author='Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen', @@ -78,6 +78,8 @@ setup( install_requires=[ 'six', 'SQLAlchemy>=0.8.0', + 'total_ordering>=0.1' + if sys.version_info[0] == 2 and sys.version_info[1] < 7 else '' ], extras_require=extras_require, cmdclass={'test': PyTest}, diff --git a/sqlalchemy_utils/__init__.py b/sqlalchemy_utils/__init__.py index 4d9b44c..0cf1f27 100644 --- a/sqlalchemy_utils/__init__.py +++ b/sqlalchemy_utils/__init__.py @@ -38,7 +38,7 @@ from .types import ( ) -__version__ = '0.17.0' +__version__ = '0.17.1' __all__ = ( diff --git a/sqlalchemy_utils/compat.py b/sqlalchemy_utils/compat.py deleted file mode 100644 index a5d2483..0000000 --- a/sqlalchemy_utils/compat.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -try: - from functools import total_ordering -except ImportError: - """ Backport to work with Python 2.6 """ - def total_ordering(cls): - """Class decorator that fills in missing ordering methods""" - convert = { - '__lt__': [ - ( - '__gt__', - lambda self, other: not (self < other or self == other) - ), - ( - '__le__', - lambda self, other: self < other or self == other - ), - ( - '__ge__', - lambda self, other: not self < other - )], - '__le__': [ - ( - '__ge__', - lambda self, other: not self <= other or self == other - ), - ( - '__lt__', - lambda self, other: self <= other and not self == other - ), - ( - '__gt__', - lambda self, other: not self <= other - )], - '__gt__': [ - ( - '__lt__', - lambda self, other: not (self > other or self == other) - ), - ( - '__ge__', - lambda self, other: self > other or self == other - ), - ( - '__le__', - lambda self, other: not self > other - )], - '__ge__': [ - ( - '__le__', - lambda self, other: (not self >= other) or self == other - ), - ( - '__gt__', - lambda self, other: self >= other and not self == other - ), - ( - '__lt__', - lambda self, other: not self >= other - )] - } - roots = set(dir(cls)) & set(convert) - if not roots: - raise ValueError( - 'must define at least one ordering operation: < > <= >=' - ) - root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__ - for opname, opfunc in convert[root]: - if opname not in roots: - opfunc.__name__ = opname - opfunc.__doc__ = getattr(int, opname).__doc__ - setattr(cls, opname, opfunc) - return cls diff --git a/sqlalchemy_utils/types/weekdays.py b/sqlalchemy_utils/types/weekdays.py index 03e47de..753e9d2 100644 --- a/sqlalchemy_utils/types/weekdays.py +++ b/sqlalchemy_utils/types/weekdays.py @@ -4,7 +4,11 @@ from sqlalchemy import types from sqlalchemy.dialects.postgresql import BIT import six -from ..compat import total_ordering +try: + from functools import total_ordering +except ImportError: + # Python 2.6 port + from total_ordering import total_ordering from sqlalchemy_utils import i18n