]> kaliko git repositories - mpd-sima.git/commitdiff
Code convention cleanup (pylint)
authorkaliko <kaliko@azylum.org>
Sat, 24 Oct 2015 10:24:31 +0000 (12:24 +0200)
committerkaliko <kaliko@azylum.org>
Sat, 24 Oct 2015 10:24:31 +0000 (12:24 +0200)
sima/client.py
sima/core.py
sima/launch.py
sima/lib/simaecho.py
sima/plugins/internal/crop.py

index 8d40edad13ba7bd99ac38af5249548d227cdb379..c509109d05f1393b4e2296aecafefb4ecf713211 100644 (file)
@@ -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')
index 2ffb04c6e44c20ae7aedc564b212838b34a8361a..eea108d3a078eb15ecc88913b8bd98a532b21abc 100644 (file)
@@ -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:
index e29fe289c1bd9df13f433496e2deaaae6f94af94..15fca4338e44ad615fe1364727bc7588713822b8 100644 (file)
@@ -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(
index beaf420dae63757b3bfa108b415c04764e289a7e..cfae27c675530b086a322c61b08fe85cbae7b945 100644 (file)
@@ -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')
index 7efb5b5491d7e40927ab87a025093967e5b0cd37..af6b3175d5203829568e44d27bf309a87a7938fc 100644 (file)
@@ -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: