From 9a061d88cf4fc459c695a07ca9225ce8ca2edfc6 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Tue, 15 Jul 2008 11:59:49 +0000 Subject: [PATCH] --- lastfm/api.py | 10 +++++----- lastfm/event.py | 1 + lastfm/geo.py | 24 ++++++++++++++++++------ lastfm/group.py | 2 ++ lastfm/playlist.py | 4 +++- lastfm/tag.py | 1 + lastfm/user.py | 4 +++- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lastfm/api.py b/lastfm/api.py index 5c65219..7a080a4 100644 --- a/lastfm/api.py +++ b/lastfm/api.py @@ -142,19 +142,19 @@ class Api(object): return Event.getInfo(self, event) def getLocation(self, name): - return Location(self, name) + return Location(self, name = name) def getCountry(self, name): - return Country(self, name) + return Country(self, name = name) def getGroup(self, name): - return Group(self, name) + return Group(self, name = name) def fetchPlaylist(self, playlistUrl): - return Playlist(self, playlistUrl) + return Playlist(self, playlistUrl = playlistUrl) def getTag(self, name): - return Tag(self, name) + return Tag(self, name = name) def getGlobalTopTags(self): return Tag.getTopTags(self) diff --git a/lastfm/event.py b/lastfm/event.py index 2359fb7..680084b 100644 --- a/lastfm/event.py +++ b/lastfm/event.py @@ -171,5 +171,6 @@ class Event(LastfmBase): from datetime import datetime import time +from error import LastfmError from artist import Artist from geo import Venue, Location, Country \ No newline at end of file diff --git a/lastfm/geo.py b/lastfm/geo.py index 88c82aa..2f46bf2 100644 --- a/lastfm/geo.py +++ b/lastfm/geo.py @@ -89,7 +89,7 @@ class Location(LastfmBase): self.__timezone = timezone def getName(self): - return self.__city + return self.__name def getCity(self): return self.__city @@ -138,12 +138,20 @@ class Location(LastfmBase): @staticmethod def hashFunc(*args, **kwds): try: - return hash("%s%s" % (kwds['latitude'], kwds['longitude'])) + return hash("latlong%s%s" % (kwds['latitude'], kwds['longitude'])) except KeyError: - raise LastfmError("latitude and longitude have to be provided for hashing") + try: + return hash("name%s" % kwds['name']) + except KeyError: + raise LastfmError("either latitude and longitude or name has to be provided for hashing") def __hash__(self): - return self.__class__.hashFunc(latitude = self.latitude, longitude = self.longitude) + if not self.name: + return self.__class__.hashFunc( + latitude = self.latitude, + longitude = self.longitude) + else: + return self.__class__.hashFunc(name = self.name) def __eq__(self, other): return self.latitude == other.latitude and self.longitude == other.longitude @@ -155,7 +163,10 @@ class Location(LastfmBase): return self.city < other.city def __repr__(self): - return "" % (self.latitude, self.longitude) + if self.name is None: + return "" % (self.latitude, self.longitude) + else: + return "" % self.name class Country(LastfmBase): """A class representing a country.""" @@ -204,6 +215,7 @@ class Country(LastfmBase): def __repr__(self): return "" % self.name + +from error import LastfmError \ No newline at end of file diff --git a/lastfm/playlist.py b/lastfm/playlist.py index 998e51a..2edbb2f 100644 --- a/lastfm/playlist.py +++ b/lastfm/playlist.py @@ -39,4 +39,6 @@ class Playlist(LastfmBase, str): return self.playlistUrl < other.playlistUrl def __repr__(self): - return "" % self.playlistUrl \ No newline at end of file + return "" % self.playlistUrl + +from error import LastfmError \ No newline at end of file diff --git a/lastfm/tag.py b/lastfm/tag.py index 5627416..04a919d 100644 --- a/lastfm/tag.py +++ b/lastfm/tag.py @@ -68,6 +68,7 @@ class Tag(LastfmBase): def __repr__(self): return "" % self.name +from error import LastfmError from album import Album from artist import Artist from track import Track \ No newline at end of file diff --git a/lastfm/user.py b/lastfm/user.py index 2de4f07..aa38d35 100644 --- a/lastfm/user.py +++ b/lastfm/user.py @@ -129,4 +129,6 @@ class User(LastfmBase): return self.name < other.name def __repr__(self): - return "" % self.name \ No newline at end of file + return "" % self.name + +from error import LastfmError \ No newline at end of file