Country and Venue now hashable, for #82

This commit is contained in:
hugovk 2014-03-02 19:34:55 +02:00
parent d0c80c8b4e
commit 9d5d56ceaf
2 changed files with 36 additions and 2 deletions

View file

@ -1011,8 +1011,11 @@ class _BaseObject(object):
return {}
def __hash__(self):
# Convert any ints (or whatever) into strings
values = map(str, self._get_params().values())
return hash(self.network) + \
hash(str(type(self)) + "".join(list(self._get_params().keys()) + list(self._get_params().values())).lower())
hash(str(type(self)) + "".join(list(self._get_params().keys()) + list(values)).lower())
class _Taggable(object):
"""Common functions for classes with tags."""
@ -1885,6 +1888,8 @@ class Country(_BaseObject):
name = None
__hash__ = _BaseObject.__hash__
def __init__(self, name, network):
_BaseObject.__init__(self, network)
@ -3577,6 +3582,8 @@ class Venue(_BaseObject):
location = None
url = None
__hash__ = _BaseObject.__hash__
def __init__(self, id, network, venue_element=None):
_BaseObject.__init__(self, network)