comparison venv/lib/python2.7/site-packages/pip/req/req_requirement.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 from pip._vendor.packaging.version import parse as parse_version
2
3
4 class InstallationCandidate(object):
5
6 def __init__(self, project, version, location):
7 self.project = project
8 self.version = parse_version(version)
9 self.location = location
10 self._key = (self.project, self.version, self.location)
11
12 def __repr__(self):
13 return "<InstallationCandidate({0!r}, {1!r}, {2!r})>".format(
14 self.project, self.version, self.location,
15 )
16
17 def __hash__(self):
18 return hash(self._key)
19
20 def __lt__(self, other):
21
22 return self._compare(other, lambda s, o: s < o)
23
24 def __le__(self, other):
25 return self._compare(other, lambda s, o: s <= o)
26
27 def __eq__(self, other):
28 return self._compare(other, lambda s, o: s == o)
29
30 def __ge__(self, other):
31 return self._compare(other, lambda s, o: s >= o)
32
33 def __gt__(self, other):
34 return self._compare(other, lambda s, o: s > o)
35
36 def __ne__(self, other):
37 return self._compare(other, lambda s, o: s != o)
38
39 def _compare(self, other, method):
40 if not isinstance(other, InstallationCandidate):
41 return NotImplemented
42
43 return method(self._key, other._key)