summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2014-12-14 13:22:29 -0500
committerDonald Stufft <donald@stufft.io>2014-12-14 13:22:29 -0500
commit6f58c6800fcbaedd883cb56cb8197bf723f9e7ab (patch)
treea1f8c96a80930554bf81837429aac26b7c86eb5b /pkg_resources.py
parent0ce9908f72838e4c95a895177981d8136db973a9 (diff)
downloadpython-setuptools-git-6f58c6800fcbaedd883cb56cb8197bf723f9e7ab.tar.gz
Add more compatability shims to SetuptoolsVersion
* Enables indexing the SetuptoolsVersion objects, triggering the legacy behavior warning. * Enables comparing the SetuptoolsVersion object to a tuple, again triggering the legacy behavior warning.
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index e1109608..5df5a3e6 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -81,6 +81,46 @@ packaging = setuptools._vendor.packaging
class _SetuptoolsVersionMixin(object):
+
+ def __lt__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) < other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__lt__(other)
+
+ def __le__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) <= other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__le__(other)
+
+ def __eq__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) == other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__eq__(other)
+
+ def __ge__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) >= other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__ge__(other)
+
+ def __gt__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) > other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__gt__(other)
+
+ def __ne__(self, other):
+ if isinstance(other, tuple):
+ return tuple(self) != other
+ else:
+ return super(_SetuptoolsVersionMixin, self).__ne__(other)
+
+ def __getitem__(self, key):
+ return tuple(self)[key]
+
def __iter__(self):
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
replace = {