First version with python3 support.

* Moved requirements*.txt files to proper spec definitions in setup.py
 * Added a new fig.compat module to store some compatibility code
This commit is contained in:
Christopher Grebs 2014-01-05 18:26:32 -08:00 • committed by Ben Firshman
commit 93b9b6fd9f
21 changed files with 83 additions and 27 deletions

23
fig/compat.py Normal file
View file

@ -0,0 +1,23 @@
# Taken from python2.7/3.3 functools
def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
def __init__(self, obj):
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
__hash__ = None
return K