Abhinav Sarkar 2008-07-15 11:59:49 +00:00
parent 7363f5cd18
commit 9a061d88cf
7 changed files with 33 additions and 13 deletions

View File

@ -142,19 +142,19 @@ class Api(object):
return Event.getInfo(self, event) return Event.getInfo(self, event)
def getLocation(self, name): def getLocation(self, name):
return Location(self, name) return Location(self, name = name)
def getCountry(self, name): def getCountry(self, name):
return Country(self, name) return Country(self, name = name)
def getGroup(self, name): def getGroup(self, name):
return Group(self, name) return Group(self, name = name)
def fetchPlaylist(self, playlistUrl): def fetchPlaylist(self, playlistUrl):
return Playlist(self, playlistUrl) return Playlist(self, playlistUrl = playlistUrl)
def getTag(self, name): def getTag(self, name):
return Tag(self, name) return Tag(self, name = name)
def getGlobalTopTags(self): def getGlobalTopTags(self):
return Tag.getTopTags(self) return Tag.getTopTags(self)

View File

@ -171,5 +171,6 @@ class Event(LastfmBase):
from datetime import datetime from datetime import datetime
import time import time
from error import LastfmError
from artist import Artist from artist import Artist
from geo import Venue, Location, Country from geo import Venue, Location, Country

View File

@ -89,7 +89,7 @@ class Location(LastfmBase):
self.__timezone = timezone self.__timezone = timezone
def getName(self): def getName(self):
return self.__city return self.__name
def getCity(self): def getCity(self):
return self.__city return self.__city
@ -138,12 +138,20 @@ class Location(LastfmBase):
@staticmethod @staticmethod
def hashFunc(*args, **kwds): def hashFunc(*args, **kwds):
try: try:
return hash("%s%s" % (kwds['latitude'], kwds['longitude'])) return hash("latlong%s%s" % (kwds['latitude'], kwds['longitude']))
except KeyError: 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): 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): def __eq__(self, other):
return self.latitude == other.latitude and self.longitude == other.longitude return self.latitude == other.latitude and self.longitude == other.longitude
@ -155,7 +163,10 @@ class Location(LastfmBase):
return self.city < other.city return self.city < other.city
def __repr__(self): def __repr__(self):
return "<lastfm.geo.Location: (%s, %s)>" % (self.latitude, self.longitude) if self.name is None:
return "<lastfm.geo.Location: (%s, %s)>" % (self.latitude, self.longitude)
else:
return "<lastfm.geo.Location: %s>" % self.name
class Country(LastfmBase): class Country(LastfmBase):
"""A class representing a country.""" """A class representing a country."""
@ -204,6 +215,7 @@ class Country(LastfmBase):
def __repr__(self): def __repr__(self):
return "<lastfm.geo.Country: %s" % self.name return "<lastfm.geo.Country: %s" % self.name
from error import LastfmError
from artist import Artist from artist import Artist
from track import Track from track import Track

View File

@ -61,3 +61,5 @@ class Group(LastfmBase):
def __repr__(self): def __repr__(self):
return "<lastfm.Group: %s>" % self.name return "<lastfm.Group: %s>" % self.name
from error import LastfmError

View File

@ -39,4 +39,6 @@ class Playlist(LastfmBase, str):
return self.playlistUrl < other.playlistUrl return self.playlistUrl < other.playlistUrl
def __repr__(self): def __repr__(self):
return "<lastfm.Playlist: %s>" % self.playlistUrl return "<lastfm.Playlist: %s>" % self.playlistUrl
from error import LastfmError

View File

@ -68,6 +68,7 @@ class Tag(LastfmBase):
def __repr__(self): def __repr__(self):
return "<lastfm.Tag: %s>" % self.name return "<lastfm.Tag: %s>" % self.name
from error import LastfmError
from album import Album from album import Album
from artist import Artist from artist import Artist
from track import Track from track import Track

View File

@ -129,4 +129,6 @@ class User(LastfmBase):
return self.name < other.name return self.name < other.name
def __repr__(self): def __repr__(self):
return "<lastfm.User: %s>" % self.name return "<lastfm.User: %s>" % self.name
from error import LastfmError