From 7ed9b4aa89c5a0c09104d63715a2fdbe9d500a15 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 2 Jul 2012 09:08:24 -0400 Subject: [PATCH] Add hashing and equality methods to Location --- common/lib/keystore/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/common/lib/keystore/__init__.py b/common/lib/keystore/__init__.py index 14716fbc2d..b204e487e2 100644 --- a/common/lib/keystore/__init__.py +++ b/common/lib/keystore/__init__.py @@ -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): """