fixed pylint warnings

This commit is contained in:
Abhinav Sarkar 2009-03-18 04:25:04 +00:00
parent 9105ddc447
commit d1656c1a84
20 changed files with 59 additions and 73 deletions

View File

@ -6,7 +6,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
__package__ = "lastfm"
from lastfm.base import LastfmBase
from lastfm.decorators import cached_property
class Api(object):
@ -647,15 +646,15 @@ class Api(object):
def _get_api_sig(self, params):
if self.secret is not None:
keys = params.keys()[:]
keys.sort()
sig = unicode()
for name in keys:
if name == 'api_sig': continue
sig += ("%s%s" % (name, params[name]))
sig += self.secret
hashed_sig = md5hash(sig)
return hashed_sig
keys = params.keys()[:]
keys.sort()
sig = unicode()
for name in keys:
if name == 'api_sig': continue
sig += ("%s%s" % (name, params[name]))
sig += self.secret
hashed_sig = md5hash(sig)
return hashed_sig
else:
raise AuthenticationFailedError("api secret must be present to call this method")

View File

@ -8,7 +8,6 @@ __package__ = "lastfm"
from lastfm.base import LastfmBase
from lastfm.mixins import Cacheable, Searchable, Sharable, Shoutable, Taggable
from lastfm.lazylist import lazylist
from lastfm.decorators import cached_property, top_property
class Artist(LastfmBase, Cacheable, Sharable, Shoutable, Searchable, Taggable):

View File

@ -78,11 +78,11 @@ def authenticate(func):
if isinstance(self, User):
username = self.name
if self.authenticated:
return func(self, *args, **kwargs)
return func(self, *args, **kwargs)
elif hasattr(self, 'user'):
username = self.user.name
if self.user.authenticated:
return func(self, *args, **kwargs)
return func(self, *args, **kwargs)
elif hasattr(self, '_subject') and isinstance(self._subject, User):
username = self._subject.name
if self._subject.authenticated:

View File

@ -9,7 +9,7 @@ __package__ = "lastfm"
from lastfm.base import LastfmBase
from lastfm.mixins import Cacheable
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):
"""A class representing a group on last.fm."""

View File

@ -21,10 +21,10 @@ class Cacheable(object):
#del kwds['subject']
if 'bypass_registry' in kwds:
del kwds['bypass_registry']
inst = object.__new__(cls)
inst.init(*args, **kwds)
return inst
del kwds['bypass_registry']
inst = object.__new__(cls)
inst.init(*args, **kwds)
return inst
key = cls._hash_func(*args, **kwds)
if subject is not None:

View File

@ -5,8 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
__package__ = "lastfm.mixins"
from lastfm.decorators import authenticate
class Sharable(object):
def init(self, api):
self._api = api

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
__package__ = "lastfm.mixins"
from lastfm.base import LastfmBase
from lastfm.decorators import cached_property, top_property
class Shoutable(object):

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
__package__ = "lastfm.mixins"
from lastfm.base import LastfmBase
from lastfm.safelist import SafeList
from lastfm.decorators import cached_property, authenticate
@ -33,9 +32,9 @@ class Taggable(object):
def add_tags(self, tags):
from lastfm.tag import Tag
while(len(tags) > 10):
section = tags[0:9]
tags = tags[9:]
self.add_tags(section)
section = tags[0:9]
tags = tags[9:]
self.add_tags(section)
if len(tags) == 0: return

View File

@ -7,7 +7,6 @@ __package__ = "lastfm"
from lastfm.base import LastfmBase
from lastfm.mixins import Cacheable, Searchable, Sharable, Taggable
from lastfm.lazylist import lazylist
from lastfm.decorators import cached_property, top_property
class Track(LastfmBase, Cacheable, Sharable, Searchable, Taggable):

View File

@ -263,6 +263,8 @@ class User(LastfmBase, Cacheable, Shoutable):
def get_recent_tracks(self, limit = None):
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')
return [
Track(

View File

@ -6,36 +6,36 @@ __license__ = "GNU Lesser General Public License"
__package__ = "lastfm"
class Wiki(object):
"""A class representing the information from the wiki of the subject."""
def __init__(self,
subject,
published = None,
summary = None,
content = None):
self._subject = subject
self._published = published
self._summary = summary
self._content = content
@property
def subject(self):
"""artist for which the biography is"""
return self._subject
@property
def published(self):
"""publication time of the biography"""
return self._published
@property
def summary(self):
"""summary of the biography"""
return self._summary
@property
def content(self):
"""content of the biography"""
return self._content
def __repr__(self):
return "<lastfm.Wiki: for %s '%s'>" % (self.subject.__class__.__name__, self.subject.name)
"""A class representing the information from the wiki of the subject."""
def __init__(self,
subject,
published = None,
summary = None,
content = None):
self._subject = subject
self._published = published
self._summary = summary
self._content = content
@property
def subject(self):
"""artist for which the biography is"""
return self._subject
@property
def published(self):
"""publication time of the biography"""
return self._published
@property
def summary(self):
"""summary of the biography"""
return self._summary
@property
def content(self):
"""content of the biography"""
return self._content
def __repr__(self):
return "<lastfm.Wiki: for %s '%s'>" % (self.subject.__class__.__name__, self.subject.name)

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener
@ -28,8 +27,8 @@ class TestArtist(unittest.TestCase):
pass
def testArtistStats(self):
self.assertEqual(self.artist.stats.listeners, 718040)
self.assertEqual(self.artist.stats.playcount, 15353197)
self.assertEqual(self.artist.stats.listeners, 718040)
self.assertEqual(self.artist.stats.playcount, 15353197)
def testArtistSimilar(self):
artists = ['Jon Bon Jovi',

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
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'))
def testCountryEvents(self):
event_ids = [961510, 925636, 959392, 875466, 951038,
event_ids = [961510, 925636, 959392, 875466, 951038,
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"
api = Api(apikey, no_cache = True)

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener

View File

@ -5,7 +5,6 @@ __version__ = "0.2"
__license__ = "GNU Lesser General Public License"
import unittest
import datetime
import sys, os
from wsgi_intercept.urllib2_intercept import install_opener
@ -41,7 +40,7 @@ class TestVenue(unittest.TestCase):
def testVenueSearch(self):
venues = [8881428, 8887127, 8894829, 8899152, 8938738,
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)
apikey = "152a230561e72192b8b0f3e42362c6ff"