From 75611a590e62f82a6f2651ac176ff619052eaa89 Mon Sep 17 00:00:00 2001 From: kaliko Date: Sat, 24 Oct 2015 12:24:31 +0200 Subject: [PATCH] Code convention cleanup (pylint) --- sima/client.py | 8 ++++---- sima/core.py | 2 +- sima/launch.py | 2 +- sima/lib/simaecho.py | 17 +++++++---------- sima/plugins/internal/crop.py | 5 +++-- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sima/client.py b/sima/client.py index 8d40eda..c509109 100644 --- a/sima/client.py +++ b/sima/client.py @@ -136,7 +136,7 @@ class PlayerClient(Player): "search", "sticker find",] track_obj = ['currentsong'] if self._comm in tracks_listing + track_obj: - # pylint: disable=w0142 + # pylint: disable=star-args if isinstance(ans, list): return [Track(**track) for track in ans] elif isinstance(ans, dict): @@ -197,7 +197,7 @@ class PlayerClient(Player): # look for exact search w/ musicbrainz_artistid exact_m = self._execute('list', ['artist', 'musicbrainz_artistid', artist.mbid]) if exact_m: - [artist.add_alias(name) for name in exact_m] + _ = [artist.add_alias(name) for name in exact_m] found = True else: artist = Artist(name=artist.name) @@ -287,7 +287,7 @@ class PlayerClient(Player): kwalbart = {'albumartist':name, 'artist':name} for album in self.list('album', 'albumartist', artist): if album and album not in albums: - albums.append(Album(name=album, **kwalbart)) + albums.append(Album(name=album, **kwalbart)) #pylint: disable=star-args for album in self.list('album', 'artist', artist): album_trks = [trk for trk in self.find('album', album)] if 'Various Artists' in [tr.albumartist for tr in album_trks]: @@ -412,7 +412,7 @@ class PlayerClient(Player): self.log.warning('Disabling MusicBrainzIdentifier') Artist.use_mbid = False else: - self.log.trace('Available metadata: %s', self._client.tagtypes()) + self.log.trace('Available metadata: %s', self._client.tagtypes()) # pylint: disable=no-member else: self.log.warning('Use of MusicBrainzIdentifier disabled!') self.log.info('Consider using MusicBrainzIdentifier for your music library') diff --git a/sima/core.py b/sima/core.py index 2ffb04c..eea108d 100644 --- a/sima/core.py +++ b/sima/core.py @@ -73,7 +73,7 @@ class Sima(Daemon): def foreach_plugin(self, method, *args, **kwds): """Plugin's callbacks dispatcher""" - self.log.trace('dispatching %s to plugins', method) + self.log.trace('dispatching %s to plugins', method) # pylint: disable=no-member for plugin in self.core_plugins: getattr(plugin, method)(*args, **kwds) for plugin in self.plugins: diff --git a/sima/launch.py b/sima/launch.py index e29fe28..15fca43 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -68,7 +68,7 @@ def load_plugins(sima, source): try: plugin_obj = getattr(mod_obj, plugin) except AttributeError as err: - logger.error('Failed to load plugin {0} ({1})'.format(plugin, err)) + logger.error('Failed to load plugin %s (%s)', plugin, err) sima.shutdown() sys.exit(1) logger.info('Loading {0} plugin: {name} ({doc})'.format( diff --git a/sima/lib/simaecho.py b/sima/lib/simaecho.py index beaf420..cfae27c 100644 --- a/sima/lib/simaecho.py +++ b/sima/lib/simaecho.py @@ -76,8 +76,7 @@ class SimaEch: if not isinstance(artist, Artist): raise TypeError('"{0!r}" not an Artist object'.format(artist)) if artist.mbid: - payload.update( - id='musicbrainz:artist:{0}'.format(artist.mbid)) + payload.update(id='musicbrainz:artist:{0}'.format(artist.mbid)) else: payload.update(name=artist.name) payload.update(bucket='id:musicbrainz') @@ -102,8 +101,8 @@ class SimaEch: # Construct URL ressource = '{0}/artist/similar'.format(SimaEch.root_url) ans = self.http(ressource, payload) - self._controls_answer(ans.json()) - for art in ans.json().get('response').get('artists'): + self._controls_answer(ans.json()) # pylint: disable=no-member + for art in ans.json().get('response').get('artists'): # pylint: disable=no-member mbid = get_mbid(art) yield Artist(mbid=mbid, name=art.get('name')) @@ -114,13 +113,11 @@ class SimaEch: # Construct URL ressource = '{0}/song/search'.format(SimaEch.root_url) ans = self.http(ressource, payload) - self._controls_answer(ans.json()) + self._controls_answer(ans.json()) # pylint: disable=no-member titles = list() - art = { - 'artist': artist.name, - 'musicbrainz_artistid': artist.mbid, - } - for song in ans.json().get('response').get('songs'): + art = {'artist': artist.name, + 'musicbrainz_artistid': artist.mbid,} + for song in ans.json().get('response').get('songs'): # pylint: disable=no-member title = song.get('title') if not art.get('musicbrainz_artistid'): art['musicbrainz_artistid'] = get_mbid(song, 'artist_foreign_ids') diff --git a/sima/plugins/internal/crop.py b/sima/plugins/internal/crop.py index 7efb5b5..af6b317 100644 --- a/sima/plugins/internal/crop.py +++ b/sima/plugins/internal/crop.py @@ -35,6 +35,7 @@ class Crop(Plugin): """ def __init__(self, daemon): super().__init__(daemon) + self.daemon = daemon self.target = None if not self.plugin_conf: return @@ -55,10 +56,10 @@ class Crop(Plugin): def callback_next_song(self): if not self.target: return - if not self._Plugin__daemon.enabled: + if not self.daemon.enabled: self.log.debug('Queueing disabled, not cropping') return False - player = self._Plugin__daemon.player + player = self.daemon.player if player.currentsong().pos > self.target: self.log.debug('cropping playlist') while player.currentsong().pos > self.target: -- 2.39.5