Do away with @functools.total_ordering to restore Python 2.6 support

* Manually implement __ne__() and __lt__()
* __gt__() and __ge__() not needed due to operator reflection
This commit is contained in:
Martin Panter 2014-01-31 01:32:46 +00:00
parent 704ed76229
commit caa609c438
2 changed files with 7 additions and 3 deletions

View File

@ -12,7 +12,7 @@ WARNING: THIS IS (STILL) WORK IN PROGRESS.
Main improvements over PIL version of OleFileIO:
------------------------------------------------
- Better compatibility with Python 2.7 (also compatible with Python 3.2+)
- Better compatibility with Python 2.6 (also compatible with Python 3.0+)
- Support for files larger than 6.8MB
- Robust: many checks to detect malformed files
- Improved API

View File

@ -224,7 +224,6 @@ import io
import sys
from PIL import _binary
import struct, array, os.path, datetime
from functools import total_ordering
#[PL] Define explicitly the public API to avoid private objects in pydoc:
__all__ = ['OleFileIO', 'isOleFile']
@ -707,7 +706,6 @@ class _OleStream(io.BytesIO):
#--- _OleDirectoryEntry -------------------------------------------------------
@total_ordering
class _OleDirectoryEntry:
"""
@ -909,6 +907,12 @@ class _OleDirectoryEntry:
return self.name < other.name
#TODO: replace by the same function as MS implementation ?
# (order by name length first, then case-insensitive order)
def __ne__(self, other):
return not self.__eq__(other)
def __le__(self, other):
return self.__eq__(other) or self.__lt__(other)
# Reflected __lt__() and __le__() will be used for __gt__() and __ge__()
def dump(self, tab = 0):