fixed pylint warnings
This commit is contained in:
parent
9105ddc447
commit
d1656c1a84
|
@ -6,7 +6,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
__package__ = "lastfm"
|
__package__ = "lastfm"
|
||||||
|
|
||||||
from lastfm.base import LastfmBase
|
|
||||||
from lastfm.decorators import cached_property
|
from lastfm.decorators import cached_property
|
||||||
|
|
||||||
class Api(object):
|
class Api(object):
|
||||||
|
@ -647,15 +646,15 @@ class Api(object):
|
||||||
|
|
||||||
def _get_api_sig(self, params):
|
def _get_api_sig(self, params):
|
||||||
if self.secret is not None:
|
if self.secret is not None:
|
||||||
keys = params.keys()[:]
|
keys = params.keys()[:]
|
||||||
keys.sort()
|
keys.sort()
|
||||||
sig = unicode()
|
sig = unicode()
|
||||||
for name in keys:
|
for name in keys:
|
||||||
if name == 'api_sig': continue
|
if name == 'api_sig': continue
|
||||||
sig += ("%s%s" % (name, params[name]))
|
sig += ("%s%s" % (name, params[name]))
|
||||||
sig += self.secret
|
sig += self.secret
|
||||||
hashed_sig = md5hash(sig)
|
hashed_sig = md5hash(sig)
|
||||||
return hashed_sig
|
return hashed_sig
|
||||||
else:
|
else:
|
||||||
raise AuthenticationFailedError("api secret must be present to call this method")
|
raise AuthenticationFailedError("api secret must be present to call this method")
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ __package__ = "lastfm"
|
||||||
|
|
||||||
from lastfm.base import LastfmBase
|
from lastfm.base import LastfmBase
|
||||||
from lastfm.mixins import Cacheable, Searchable, Sharable, Shoutable, Taggable
|
from lastfm.mixins import Cacheable, Searchable, Sharable, Shoutable, Taggable
|
||||||
from lastfm.lazylist import lazylist
|
|
||||||
from lastfm.decorators import cached_property, top_property
|
from lastfm.decorators import cached_property, top_property
|
||||||
|
|
||||||
class Artist(LastfmBase, Cacheable, Sharable, Shoutable, Searchable, Taggable):
|
class Artist(LastfmBase, Cacheable, Sharable, Shoutable, Searchable, Taggable):
|
||||||
|
|
|
@ -78,11 +78,11 @@ def authenticate(func):
|
||||||
if isinstance(self, User):
|
if isinstance(self, User):
|
||||||
username = self.name
|
username = self.name
|
||||||
if self.authenticated:
|
if self.authenticated:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
elif hasattr(self, 'user'):
|
elif hasattr(self, 'user'):
|
||||||
username = self.user.name
|
username = self.user.name
|
||||||
if self.user.authenticated:
|
if self.user.authenticated:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
elif hasattr(self, '_subject') and isinstance(self._subject, User):
|
elif hasattr(self, '_subject') and isinstance(self._subject, User):
|
||||||
username = self._subject.name
|
username = self._subject.name
|
||||||
if self._subject.authenticated:
|
if self._subject.authenticated:
|
||||||
|
|
|
@ -9,7 +9,7 @@ __package__ = "lastfm"
|
||||||
from lastfm.base import LastfmBase
|
from lastfm.base import LastfmBase
|
||||||
from lastfm.mixins import Cacheable
|
from lastfm.mixins import Cacheable
|
||||||
from lastfm.lazylist import lazylist
|
from lastfm.lazylist import lazylist
|
||||||
from lastfm.decorators import cached_property, top_property, depaginate
|
from lastfm.decorators import cached_property, depaginate
|
||||||
|
|
||||||
class Group(LastfmBase, Cacheable):
|
class Group(LastfmBase, Cacheable):
|
||||||
"""A class representing a group on last.fm."""
|
"""A class representing a group on last.fm."""
|
||||||
|
|
|
@ -21,10 +21,10 @@ class Cacheable(object):
|
||||||
#del kwds['subject']
|
#del kwds['subject']
|
||||||
|
|
||||||
if 'bypass_registry' in kwds:
|
if 'bypass_registry' in kwds:
|
||||||
del kwds['bypass_registry']
|
del kwds['bypass_registry']
|
||||||
inst = object.__new__(cls)
|
inst = object.__new__(cls)
|
||||||
inst.init(*args, **kwds)
|
inst.init(*args, **kwds)
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
key = cls._hash_func(*args, **kwds)
|
key = cls._hash_func(*args, **kwds)
|
||||||
if subject is not None:
|
if subject is not None:
|
||||||
|
|
|
@ -5,8 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
__package__ = "lastfm.mixins"
|
__package__ = "lastfm.mixins"
|
||||||
|
|
||||||
from lastfm.decorators import authenticate
|
|
||||||
|
|
||||||
class Sharable(object):
|
class Sharable(object):
|
||||||
def init(self, api):
|
def init(self, api):
|
||||||
self._api = api
|
self._api = api
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
__package__ = "lastfm.mixins"
|
__package__ = "lastfm.mixins"
|
||||||
|
|
||||||
from lastfm.base import LastfmBase
|
|
||||||
from lastfm.decorators import cached_property, top_property
|
from lastfm.decorators import cached_property, top_property
|
||||||
|
|
||||||
class Shoutable(object):
|
class Shoutable(object):
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
__package__ = "lastfm.mixins"
|
__package__ = "lastfm.mixins"
|
||||||
|
|
||||||
from lastfm.base import LastfmBase
|
|
||||||
from lastfm.safelist import SafeList
|
from lastfm.safelist import SafeList
|
||||||
from lastfm.decorators import cached_property, authenticate
|
from lastfm.decorators import cached_property, authenticate
|
||||||
|
|
||||||
|
@ -33,9 +32,9 @@ class Taggable(object):
|
||||||
def add_tags(self, tags):
|
def add_tags(self, tags):
|
||||||
from lastfm.tag import Tag
|
from lastfm.tag import Tag
|
||||||
while(len(tags) > 10):
|
while(len(tags) > 10):
|
||||||
section = tags[0:9]
|
section = tags[0:9]
|
||||||
tags = tags[9:]
|
tags = tags[9:]
|
||||||
self.add_tags(section)
|
self.add_tags(section)
|
||||||
|
|
||||||
if len(tags) == 0: return
|
if len(tags) == 0: return
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ __package__ = "lastfm"
|
||||||
|
|
||||||
from lastfm.base import LastfmBase
|
from lastfm.base import LastfmBase
|
||||||
from lastfm.mixins import Cacheable, Searchable, Sharable, Taggable
|
from lastfm.mixins import Cacheable, Searchable, Sharable, Taggable
|
||||||
from lastfm.lazylist import lazylist
|
|
||||||
from lastfm.decorators import cached_property, top_property
|
from lastfm.decorators import cached_property, top_property
|
||||||
|
|
||||||
class Track(LastfmBase, Cacheable, Sharable, Searchable, Taggable):
|
class Track(LastfmBase, Cacheable, Sharable, Searchable, Taggable):
|
||||||
|
|
|
@ -263,6 +263,8 @@ class User(LastfmBase, Cacheable, Shoutable):
|
||||||
|
|
||||||
def get_recent_tracks(self, limit = None):
|
def get_recent_tracks(self, limit = None):
|
||||||
params = self._default_params({'method': 'user.getRecentTracks'})
|
params = self._default_params({'method': 'user.getRecentTracks'})
|
||||||
|
if limit is not None:
|
||||||
|
params.update({'limit': limit})
|
||||||
data = self._api._fetch_data(params, no_cache = True).find('recenttracks')
|
data = self._api._fetch_data(params, no_cache = True).find('recenttracks')
|
||||||
return [
|
return [
|
||||||
Track(
|
Track(
|
||||||
|
|
|
@ -6,36 +6,36 @@ __license__ = "GNU Lesser General Public License"
|
||||||
__package__ = "lastfm"
|
__package__ = "lastfm"
|
||||||
|
|
||||||
class Wiki(object):
|
class Wiki(object):
|
||||||
"""A class representing the information from the wiki of the subject."""
|
"""A class representing the information from the wiki of the subject."""
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
subject,
|
subject,
|
||||||
published = None,
|
published = None,
|
||||||
summary = None,
|
summary = None,
|
||||||
content = None):
|
content = None):
|
||||||
self._subject = subject
|
self._subject = subject
|
||||||
self._published = published
|
self._published = published
|
||||||
self._summary = summary
|
self._summary = summary
|
||||||
self._content = content
|
self._content = content
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subject(self):
|
def subject(self):
|
||||||
"""artist for which the biography is"""
|
"""artist for which the biography is"""
|
||||||
return self._subject
|
return self._subject
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def published(self):
|
def published(self):
|
||||||
"""publication time of the biography"""
|
"""publication time of the biography"""
|
||||||
return self._published
|
return self._published
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def summary(self):
|
def summary(self):
|
||||||
"""summary of the biography"""
|
"""summary of the biography"""
|
||||||
return self._summary
|
return self._summary
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content(self):
|
def content(self):
|
||||||
"""content of the biography"""
|
"""content of the biography"""
|
||||||
return self._content
|
return self._content
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<lastfm.Wiki: for %s '%s'>" % (self.subject.__class__.__name__, self.subject.name)
|
return "<lastfm.Wiki: for %s '%s'>" % (self.subject.__class__.__name__, self.subject.name)
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
@ -28,8 +27,8 @@ class TestArtist(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def testArtistStats(self):
|
def testArtistStats(self):
|
||||||
self.assertEqual(self.artist.stats.listeners, 718040)
|
self.assertEqual(self.artist.stats.listeners, 718040)
|
||||||
self.assertEqual(self.artist.stats.playcount, 15353197)
|
self.assertEqual(self.artist.stats.playcount, 15353197)
|
||||||
|
|
||||||
def testArtistSimilar(self):
|
def testArtistSimilar(self):
|
||||||
artists = ['Jon Bon Jovi',
|
artists = ['Jon Bon Jovi',
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
@ -91,9 +90,9 @@ class TestGeo(unittest.TestCase):
|
||||||
self.assertEqual((top_track.name, top_track.artist.name), ('Dream Fighter', 'Perfume'))
|
self.assertEqual((top_track.name, top_track.artist.name), ('Dream Fighter', 'Perfume'))
|
||||||
|
|
||||||
def testCountryEvents(self):
|
def testCountryEvents(self):
|
||||||
event_ids = [961510, 925636, 959392, 875466, 951038,
|
event_ids = [961510, 925636, 959392, 875466, 951038,
|
||||||
950520, 957543, 930614, 871240, 857063]
|
950520, 957543, 930614, 871240, 857063]
|
||||||
self.assertEqual([e.id for e in self.country.events[:10]], event_ids)
|
self.assertEqual([e.id for e in self.country.events[:10]], event_ids)
|
||||||
|
|
||||||
apikey = "152a230561e72192b8b0f3e42362c6ff"
|
apikey = "152a230561e72192b8b0f3e42362c6ff"
|
||||||
api = Api(apikey, no_cache = True)
|
api = Api(apikey, no_cache = True)
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
|
|
@ -5,7 +5,6 @@ __version__ = "0.2"
|
||||||
__license__ = "GNU Lesser General Public License"
|
__license__ = "GNU Lesser General Public License"
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import datetime
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from wsgi_intercept.urllib2_intercept import install_opener
|
from wsgi_intercept.urllib2_intercept import install_opener
|
||||||
|
@ -41,7 +40,7 @@ class TestVenue(unittest.TestCase):
|
||||||
def testVenueSearch(self):
|
def testVenueSearch(self):
|
||||||
venues = [8881428, 8887127, 8894829, 8899152, 8938738,
|
venues = [8881428, 8887127, 8894829, 8899152, 8938738,
|
||||||
8778901, 8779255, 8779726, 8802306, 8781168]
|
8778901, 8779255, 8779726, 8802306, 8781168]
|
||||||
self.assertEqual([v.id for v
|
self.assertEqual([venue.id for venue
|
||||||
in list(api.search_venue('stadium')[:10])], venues)
|
in list(api.search_venue('stadium')[:10])], venues)
|
||||||
|
|
||||||
apikey = "152a230561e72192b8b0f3e42362c6ff"
|
apikey = "152a230561e72192b8b0f3e42362c6ff"
|
||||||
|
|
Loading…
Reference in New Issue