changed the default value of extra_params argument in the _default_params methods to None from {}
parent
394310c60f
commit
9105ddc447
|
@ -686,7 +686,8 @@ import urlparse
|
||||||
|
|
||||||
from lastfm.album import Album
|
from lastfm.album import Album
|
||||||
from lastfm.artist import Artist
|
from lastfm.artist import Artist
|
||||||
from lastfm.error import error_map, LastfmError, OperationFailedError, AuthenticationFailedError
|
from lastfm.error import error_map, LastfmError, OperationFailedError, AuthenticationFailedError,\
|
||||||
|
InvalidParametersError
|
||||||
from lastfm.event import Event
|
from lastfm.event import Event
|
||||||
from lastfm.filecache import FileCache
|
from lastfm.filecache import FileCache
|
||||||
from lastfm.geo import Location, Country
|
from lastfm.geo import Location, Country
|
||||||
|
|
|
@ -369,10 +369,11 @@ class Artist(LastfmBase, Cacheable, Sharable, Shoutable, Searchable, Taggable):
|
||||||
a._fill_info()
|
a._fill_info()
|
||||||
return a
|
return a
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise InvalidParametersError("artist has to be provided.")
|
raise InvalidParametersError("artist has to be provided.")
|
||||||
params = {'artist': self.name}
|
params = {'artist': self.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,14 @@ __package__ = "lastfm"
|
||||||
class LastfmBase(object):
|
class LastfmBase(object):
|
||||||
"""Base class for all the classes in this package"""
|
"""Base class for all the classes in this package"""
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
raise NotImplementedError("The subclass must override this method")
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
raise NotImplementedError("The subclass must override this method")
|
||||||
|
|
||||||
def __gt__(self, other):
|
def __gt__(self, other):
|
||||||
return not (self.__lt__(other) or self.__eq(other))
|
return not (self.__lt__(other) or self.__eq__(other))
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
|
@ -287,10 +287,11 @@ class Event(LastfmBase, Cacheable, Sharable, Shoutable):
|
||||||
tag = data.findtext('tag')
|
tag = data.findtext('tag')
|
||||||
)
|
)
|
||||||
|
|
||||||
def _default_params(self, extra_params = []):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.id:
|
if not self.id:
|
||||||
raise InvalidParametersError("id has to be provided.")
|
raise InvalidParametersError("id has to be provided.")
|
||||||
params = {'event': self.id}
|
params = {'event': self.id}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -215,10 +215,11 @@ class Group(LastfmBase, Cacheable):
|
||||||
url = u.findtext('url')
|
url = u.findtext('url')
|
||||||
)
|
)
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise InvalidParametersError("group has to be provided.")
|
raise InvalidParametersError("group has to be provided.")
|
||||||
params = {'group': self.name}
|
params = {'group': self.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -51,3 +51,7 @@ class Cacheable(object):
|
||||||
#print "not already registered: %s" % ob.__class__
|
#print "not already registered: %s" % ob.__class__
|
||||||
Cacheable.registry[ob.__class__][key] = ob
|
Cacheable.registry[ob.__class__][key] = ob
|
||||||
return (ob, False)
|
return (ob, False)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _hash_func(*args, **kwds):
|
||||||
|
raise NotImplementedError("The subclass must override this method")
|
||||||
|
|
|
@ -26,5 +26,8 @@ class Sharable(object):
|
||||||
params['recipient'] = ",".join(recipient)
|
params['recipient'] = ",".join(recipient)
|
||||||
self._api._post_data(params)
|
self._api._post_data(params)
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
|
if extra_params is not None:
|
||||||
return extra_params
|
return extra_params
|
||||||
|
else:
|
||||||
|
return {}
|
|
@ -34,8 +34,11 @@ class Shoutable(object):
|
||||||
"""recent shout for this subject"""
|
"""recent shout for this subject"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
|
if extra_params is not None:
|
||||||
return extra_params
|
return extra_params
|
||||||
|
else:
|
||||||
|
return {}
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
|
@ -66,5 +66,8 @@ class Taggable(object):
|
||||||
self._api._post_data(params)
|
self._api._post_data(params)
|
||||||
self._tags = None
|
self._tags = None
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
|
if extra_params is not None:
|
||||||
return extra_params
|
return extra_params
|
||||||
|
else:
|
||||||
|
return {}
|
|
@ -227,10 +227,11 @@ class Tag(LastfmBase, Cacheable, Searchable):
|
||||||
for t in data.findall('tag')
|
for t in data.findall('tag')
|
||||||
]
|
]
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise InvalidParametersError("tag has to be provided.")
|
raise InvalidParametersError("tag has to be provided.")
|
||||||
params = {'tag': self.name}
|
params = {'tag': self.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -272,10 +272,11 @@ class Track(LastfmBase, Cacheable, Sharable, Searchable, Taggable):
|
||||||
t._fill_info()
|
t._fill_info()
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not (self.artist and self.name):
|
if not (self.artist and self.name):
|
||||||
raise InvalidParametersError("artist and track have to be provided.")
|
raise InvalidParametersError("artist and track have to be provided.")
|
||||||
params = {'artist': self.artist.name, 'track': self.name}
|
params = {'artist': self.artist.name, 'track': self.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
|
@ -621,10 +621,11 @@ class User(LastfmBase, Cacheable, Shoutable):
|
||||||
user._stats = Stats(subject = user, playcount = data.findtext('playcount'))
|
user._stats = Stats(subject = user, playcount = data.findtext('playcount'))
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise InvalidParametersError("user has to be provided.")
|
raise InvalidParametersError("user has to be provided.")
|
||||||
params = {'user': self.name}
|
params = {'user': self.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
@ -883,10 +884,11 @@ class User(LastfmBase, Cacheable, Shoutable):
|
||||||
self._api._post_data(params)
|
self._api._post_data(params)
|
||||||
self._tracks = None
|
self._tracks = None
|
||||||
|
|
||||||
def _default_params(self, extra_params = {}):
|
def _default_params(self, extra_params = None):
|
||||||
if not self.user.name:
|
if not self.user.name:
|
||||||
raise InvalidParametersError("user has to be provided.")
|
raise InvalidParametersError("user has to be provided.")
|
||||||
params = {'user': self.user.name}
|
params = {'user': self.user.name}
|
||||||
|
if extra_params is not None:
|
||||||
params.update(extra_params)
|
params.update(extra_params)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue