[gnome-music/wip/jfelder/mpris-cleanup: 65/67] mpris: Fix some PEP-8 issues



commit ef5188124ba27b51cbecdc65553d2c697cd20064
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Mar 18 15:09:56 2019 +0100

    mpris: Fix some PEP-8 issues
    
    Mostly some lines being too long and some wrong indentation.

 gnomemusic/mpris.py | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 4ad1c7e4..06d86c0c 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -547,11 +547,12 @@ class MPRIS(DBusInterface):
             return
 
         self._previous_playback_status = playback_status
-        self._properties_changed(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
-                               {
-                                   'PlaybackStatus': GLib.Variant('s', playback_status),
-                               },
-                               [])
+        self._properties_changed(
+            MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
+            {
+                'PlaybackStatus': GLib.Variant('s', playback_status),
+            },
+            [])
 
     @log
     def _on_repeat_mode_changed(self, player, param):
@@ -606,11 +607,12 @@ class MPRIS(DBusInterface):
     def _reload_playlists(self):
         def query_playlists_callback(playlists):
             self._playlists = playlists
-            self._properties_changed(MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
-                                   {
-                                       'PlaylistCount': GLib.Variant('u', len(playlists)),
-                                   },
-                                   [])
+            self._properties_changed(
+                MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+                {
+                    'PlaylistCount': GLib.Variant('u', len(playlists)),
+                },
+                [])
 
         self._query_playlists(query_playlists_callback)
 
@@ -809,19 +811,23 @@ class MPRIS(DBusInterface):
         elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYER_IFACE:
             position_msecond = int(self._player.get_position() * 1e6)
             metadata = self._get_metadata(self._player.props.current_song)
+            playback_status = self._get_playback_status()
+            is_shuffle = (self._player.props.repeat_mode == RepeatMode.SHUFFLE)
+            can_play = (self._player.props.current_song is not None)
+            has_previous = (self._player.props.has_previous)
             return {
-                'PlaybackStatus': GLib.Variant('s', self._get_playback_status()),
+                'PlaybackStatus': GLib.Variant('s', playback_status),
                 'LoopStatus': GLib.Variant('s', self._get_loop_status()),
                 'Rate': GLib.Variant('d', 1.0),
-                'Shuffle': GLib.Variant('b', self._player.props.repeat_mode == RepeatMode.SHUFFLE),
+                'Shuffle': GLib.Variant('b', is_shuffle),
                 'Metadata': GLib.Variant('a{sv}', metadata),
                 'Position': GLib.Variant('x', position_msecond),
                 'MinimumRate': GLib.Variant('d', 1.0),
                 'MaximumRate': GLib.Variant('d', 1.0),
                 'CanGoNext': GLib.Variant('b', self._player.props.has_next),
-                'CanGoPrevious': GLib.Variant('b', self._player.props.has_previous),
-                'CanPlay': GLib.Variant('b', self._player.props.current_song is not None),
-                'CanPause': GLib.Variant('b', self._player.props.current_song is not None),
+                'CanGoPrevious': GLib.Variant('b', has_previous),
+                'CanPlay': GLib.Variant('b', can_play),
+                'CanPause': GLib.Variant('b', can_play),
                 'CanSeek': GLib.Variant('b', True),
                 'CanControl': GLib.Variant('b', True),
             }
@@ -831,10 +837,11 @@ class MPRIS(DBusInterface):
                 'CanEditTracks': GLib.Variant('b', False)
             }
         elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE:
+            active_playlist = self._get_active_playlist()
             return {
                 'PlaylistCount': GLib.Variant('u', len(self._playlists)),
                 'Orderings': GLib.Variant('as', ['Alphabetical']),
-                'ActivePlaylist': GLib.Variant('(b(oss))', self._get_active_playlist()),
+                'ActivePlaylist': GLib.Variant('(b(oss))', active_playlist),
             }
         elif interface_name == 'org.freedesktop.DBus.Properties':
             return {}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]