aboutsummaryrefslogtreecommitdiffstats
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
commite27bb7d12b73046f4805025fd2a53fc6bb3b1dfa (patch)
tree23f54ef02062fcad8601db8b4978a55a6135e620 /pkg_resources.py
parent5bf45c863a9b88a2c62fdaaeb75538c426ab5d41 (diff)
downloadexternal_python_setuptools-e27bb7d12b73046f4805025fd2a53fc6bb3b1dfa.tar.gz
external_python_setuptools-e27bb7d12b73046f4805025fd2a53fc6bb3b1dfa.tar.bz2
external_python_setuptools-e27bb7d12b73046f4805025fd2a53fc6bb3b1dfa.zip
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 = {