This commit is contained in:
parent
7363f5cd18
commit
9a061d88cf
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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 "<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):
|
||||
"""A class representing a country."""
|
||||
|
@ -204,6 +215,7 @@ class Country(LastfmBase):
|
|||
|
||||
def __repr__(self):
|
||||
return "<lastfm.geo.Country: %s" % self.name
|
||||
|
||||
|
||||
from error import LastfmError
|
||||
from artist import Artist
|
||||
from track import Track
|
|
@ -61,3 +61,5 @@ class Group(LastfmBase):
|
|||
|
||||
def __repr__(self):
|
||||
return "<lastfm.Group: %s>" % self.name
|
||||
|
||||
from error import LastfmError
|
|
@ -39,4 +39,6 @@ class Playlist(LastfmBase, str):
|
|||
return self.playlistUrl < other.playlistUrl
|
||||
|
||||
def __repr__(self):
|
||||
return "<lastfm.Playlist: %s>" % self.playlistUrl
|
||||
return "<lastfm.Playlist: %s>" % self.playlistUrl
|
||||
|
||||
from error import LastfmError
|
|
@ -68,6 +68,7 @@ class Tag(LastfmBase):
|
|||
def __repr__(self):
|
||||
return "<lastfm.Tag: %s>" % self.name
|
||||
|
||||
from error import LastfmError
|
||||
from album import Album
|
||||
from artist import Artist
|
||||
from track import Track
|
|
@ -129,4 +129,6 @@ class User(LastfmBase):
|
|||
return self.name < other.name
|
||||
|
||||
def __repr__(self):
|
||||
return "<lastfm.User: %s>" % self.name
|
||||
return "<lastfm.User: %s>" % self.name
|
||||
|
||||
from error import LastfmError
|
Loading…
Reference in New Issue