changed the default value of extra_params argument in the _default_params methods to None from {}
This commit is contained in:
parent
394310c60f
commit
9105ddc447
@ -686,7 +686,8 @@ import urlparse
|
||||
|
||||
from lastfm.album import Album
|
||||
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.filecache import FileCache
|
||||
from lastfm.geo import Location, Country
|
||||
|
@ -369,11 +369,12 @@ class Artist(LastfmBase, Cacheable, Sharable, Shoutable, Searchable, Taggable):
|
||||
a._fill_info()
|
||||
return a
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.name:
|
||||
raise InvalidParametersError("artist has to be provided.")
|
||||
params = {'artist': self.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
@ -8,9 +8,15 @@ __package__ = "lastfm"
|
||||
|
||||
class LastfmBase(object):
|
||||
"""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):
|
||||
return not (self.__lt__(other) or self.__eq(other))
|
||||
return not (self.__lt__(other) or self.__eq__(other))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
@ -287,11 +287,12 @@ class Event(LastfmBase, Cacheable, Sharable, Shoutable):
|
||||
tag = data.findtext('tag')
|
||||
)
|
||||
|
||||
def _default_params(self, extra_params = []):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.id:
|
||||
raise InvalidParametersError("id has to be provided.")
|
||||
params = {'event': self.id}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
@ -215,11 +215,12 @@ class Group(LastfmBase, Cacheable):
|
||||
url = u.findtext('url')
|
||||
)
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.name:
|
||||
raise InvalidParametersError("group has to be provided.")
|
||||
params = {'group': self.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
@ -51,3 +51,7 @@ class Cacheable(object):
|
||||
#print "not already registered: %s" % ob.__class__
|
||||
Cacheable.registry[ob.__class__][key] = ob
|
||||
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)
|
||||
self._api._post_data(params)
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
return extra_params
|
||||
def _default_params(self, extra_params = None):
|
||||
if extra_params is not None:
|
||||
return extra_params
|
||||
else:
|
||||
return {}
|
@ -34,8 +34,11 @@ class Shoutable(object):
|
||||
"""recent shout for this subject"""
|
||||
pass
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
return extra_params
|
||||
def _default_params(self, extra_params = None):
|
||||
if extra_params is not None:
|
||||
return extra_params
|
||||
else:
|
||||
return {}
|
||||
|
||||
from datetime import datetime
|
||||
import time
|
@ -66,5 +66,8 @@ class Taggable(object):
|
||||
self._api._post_data(params)
|
||||
self._tags = None
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
return extra_params
|
||||
def _default_params(self, extra_params = None):
|
||||
if extra_params is not None:
|
||||
return extra_params
|
||||
else:
|
||||
return {}
|
@ -227,11 +227,12 @@ class Tag(LastfmBase, Cacheable, Searchable):
|
||||
for t in data.findall('tag')
|
||||
]
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.name:
|
||||
raise InvalidParametersError("tag has to be provided.")
|
||||
params = {'tag': self.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
@ -272,11 +272,12 @@ class Track(LastfmBase, Cacheable, Sharable, Searchable, Taggable):
|
||||
t._fill_info()
|
||||
return t
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not (self.artist and self.name):
|
||||
raise InvalidParametersError("artist and track have to be provided.")
|
||||
params = {'artist': self.artist.name, 'track': self.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
@ -621,11 +621,12 @@ class User(LastfmBase, Cacheable, Shoutable):
|
||||
user._stats = Stats(subject = user, playcount = data.findtext('playcount'))
|
||||
return user
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.name:
|
||||
raise InvalidParametersError("user has to be provided.")
|
||||
params = {'user': self.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
@ -883,11 +884,12 @@ class User(LastfmBase, Cacheable, Shoutable):
|
||||
self._api._post_data(params)
|
||||
self._tracks = None
|
||||
|
||||
def _default_params(self, extra_params = {}):
|
||||
def _default_params(self, extra_params = None):
|
||||
if not self.user.name:
|
||||
raise InvalidParametersError("user has to be provided.")
|
||||
params = {'user': self.user.name}
|
||||
params.update(extra_params)
|
||||
if extra_params is not None:
|
||||
params.update(extra_params)
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user