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



commit 3525ba5ff4278ff6eaba4d11357420646dcf9371
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 075c0b6e..1db999d5 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -548,11 +548,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):
@@ -591,11 +592,12 @@ class MPRIS(DBusInterface):
     def _reload_playlists(self):
         def query_playlists_callback(playlists):
             self._stored_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)
 
@@ -788,19 +790,23 @@ class MPRIS(DBusInterface):
             }
         elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYER_IFACE:
             position_msecond = int(self._player.get_position() * 1e6)
+            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}', self._get_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),
             }
@@ -811,10 +817,11 @@ class MPRIS(DBusInterface):
             }
         elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE:
             playlist_count = len(self._stored_playlists)
+            active_playlist = self._get_active_playlist()
             return {
                 'PlaylistCount': GLib.Variant('u', playlist_count),
                 '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]