summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2009-09-12 17:33:49 +0200
committerMartin v. Löwis <martin@v.loewis.de>2009-09-12 17:33:49 +0200
commitf6747b162905d4fe48701a8655c857d8ef363b9d (patch)
tree4ef4f8651dc5adc9bff8754f347edc362cf2b794 /pkg_resources.py
parent63ad9ff720754e36a2b0299f2c857228f32b0c52 (diff)
downloadpython-setuptools-git-f6747b162905d4fe48701a8655c857d8ef363b9d.tar.gz
Add rich comparison to distribution object.
--HG-- branch : distribute extra : rebase_source : 858ac6c7ad2389ba70d443480d955d3ec1e39d76
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index f34adfda..910c3089 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -2050,8 +2050,20 @@ class Distribution(object):
self.platform
)
)
- def __cmp__(self, other): return cmp(self.hashcmp, other)
def __hash__(self): return hash(self.hashcmp)
+ def __lt__(self, other):
+ return self.hashcmp < other.hashcmp
+ def __le__(self, other):
+ return self.hashcmp <= other.hashcmp
+ def __gt__(self, other):
+ return self.hashcmp > other.hashcmp
+ def __ge__(self, other):
+ return self.hashcmp >= other.hashcmp
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ # It's not a Distribution, so they are not equal
+ return False
+ return self.hashcmp == other.hashcmp
# These properties have to be lazy so that we don't have to load any
# metadata until/unless it's actually needed. (i.e., some distributions