From d1656c1a84049ed4365fc7932398c388c9b54c06 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Wed, 18 Mar 2009 04:25:04 +0000 Subject: [PATCH] fixed pylint warnings --- lastfm/api.py | 19 ++++++----- lastfm/artist.py | 1 - lastfm/decorators.py | 4 +-- lastfm/group.py | 2 +- lastfm/mixins/cacheable.py | 8 ++--- lastfm/mixins/sharable.py | 2 -- lastfm/mixins/shoutable.py | 1 - lastfm/mixins/taggable.py | 7 ++-- lastfm/track.py | 1 - lastfm/user.py | 2 ++ lastfm/wiki.py | 66 +++++++++++++++++++------------------- test/test_artist.py | 5 ++- test/test_event.py | 1 - test/test_geo.py | 5 ++- test/test_group.py | 1 - test/test_playlist.py | 1 - test/test_tag.py | 1 - test/test_track.py | 1 - test/test_user.py | 1 - test/test_venue.py | 3 +- 20 files changed, 59 insertions(+), 73 deletions(-) diff --git a/lastfm/api.py b/lastfm/api.py index d10e8ec..2cdb7ae 100644 --- a/lastfm/api.py +++ b/lastfm/api.py @@ -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") diff --git a/lastfm/artist.py b/lastfm/artist.py index b48cda7..a88d5d4 100644 --- a/lastfm/artist.py +++ b/lastfm/artist.py @@ -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): diff --git a/lastfm/decorators.py b/lastfm/decorators.py index 70d09e4..064b731 100644 --- a/lastfm/decorators.py +++ b/lastfm/decorators.py @@ -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: diff --git a/lastfm/group.py b/lastfm/group.py index 5ff47a0..e49b4b6 100644 --- a/lastfm/group.py +++ b/lastfm/group.py @@ -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.""" diff --git a/lastfm/mixins/cacheable.py b/lastfm/mixins/cacheable.py index d9ff828..e5df5a9 100644 --- a/lastfm/mixins/cacheable.py +++ b/lastfm/mixins/cacheable.py @@ -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: diff --git a/lastfm/mixins/sharable.py b/lastfm/mixins/sharable.py index 3b8aa93..70844c8 100644 --- a/lastfm/mixins/sharable.py +++ b/lastfm/mixins/sharable.py @@ -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 diff --git a/lastfm/mixins/shoutable.py b/lastfm/mixins/shoutable.py index 0cda591..5b3ac47 100644 --- a/lastfm/mixins/shoutable.py +++ b/lastfm/mixins/shoutable.py @@ -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): diff --git a/lastfm/mixins/taggable.py b/lastfm/mixins/taggable.py index 67e9824..f23a313 100644 --- a/lastfm/mixins/taggable.py +++ b/lastfm/mixins/taggable.py @@ -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 diff --git a/lastfm/track.py b/lastfm/track.py index a7b9566..a2d8440 100644 --- a/lastfm/track.py +++ b/lastfm/track.py @@ -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): diff --git a/lastfm/user.py b/lastfm/user.py index f940363..55ee06d 100644 --- a/lastfm/user.py +++ b/lastfm/user.py @@ -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( diff --git a/lastfm/wiki.py b/lastfm/wiki.py index 599f54f..2ec249c 100644 --- a/lastfm/wiki.py +++ b/lastfm/wiki.py @@ -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 "" % (self.subject.__class__.__name__, self.subject.name) \ No newline at end of file + """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 "" % (self.subject.__class__.__name__, self.subject.name) \ No newline at end of file diff --git a/test/test_artist.py b/test/test_artist.py index 614f81e..f658f2d 100644 --- a/test/test_artist.py +++ b/test/test_artist.py @@ -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', diff --git a/test/test_event.py b/test/test_event.py index ede8cbf..ad580a2 100644 --- a/test/test_event.py +++ b/test/test_event.py @@ -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 diff --git a/test/test_geo.py b/test/test_geo.py index 763a328..98c880c 100644 --- a/test/test_geo.py +++ b/test/test_geo.py @@ -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) diff --git a/test/test_group.py b/test/test_group.py index 891f5b2..a647dff 100644 --- a/test/test_group.py +++ b/test/test_group.py @@ -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 diff --git a/test/test_playlist.py b/test/test_playlist.py index 51af6a1..56afa41 100644 --- a/test/test_playlist.py +++ b/test/test_playlist.py @@ -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 diff --git a/test/test_tag.py b/test/test_tag.py index 3921044..0782689 100644 --- a/test/test_tag.py +++ b/test/test_tag.py @@ -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 diff --git a/test/test_track.py b/test/test_track.py index 5c536ae..9dfa1b8 100644 --- a/test/test_track.py +++ b/test/test_track.py @@ -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 diff --git a/test/test_user.py b/test/test_user.py index 07e4649..6a36354 100644 --- a/test/test_user.py +++ b/test/test_user.py @@ -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 diff --git a/test/test_venue.py b/test/test_venue.py index 70c8f95..19f8d64 100644 --- a/test/test_venue.py +++ b/test/test_venue.py @@ -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"