Add hashing and equality methods to Location

This commit is contained in:
Calen Pennington
2012-07-02 09:08:24 -04:00
parent 736148f21d
commit 7ed9b4aa89

View File

@@ -101,9 +101,6 @@ class Location(object):
if val is not None and INVALID_CHARS.search(val) is not None:
raise InvalidLocationError(location)
def __str__(self):
return self.url()
def url(self):
"""
Return a string containing the URL for this location
@@ -136,6 +133,19 @@ class Location(object):
'name': self.name,
'revision': self.revision}
def __str__(self):
return self.url()
def __repr__(self):
return 'Location(%r)' % str(self)
def __hash__(self):
return self.url()
def __eq__(self, other):
return (isinstance(other, Location) and
str(self) == str(other))
class ModuleStore(object):
"""