[gnome-music/wip/mschraal/pep8morefixes] PEP-8 fixes
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/pep8morefixes] PEP-8 fixes
- Date: Fri, 15 Dec 2017 19:54:51 +0000 (UTC)
commit f5226b21e9d2336aa702f98bbc2a51e7ae04c6a0
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Dec 15 20:52:22 2017 +0100
PEP-8 fixes
Cleanup left-over errors, for a clean CI run to build on.
gnomemusic/notification.py | 27 +++++++++++++--------------
gnomemusic/playlists.py | 30 +++++++++++++++++++++---------
gnomemusic/toolbar.py | 32 +++++++++++++++++---------------
gnomemusic/views/albumsview.py | 24 +++++++++++-------------
gnomemusic/views/artistsview.py | 10 +++++-----
gnomemusic/views/baseview.py | 4 ++--
gnomemusic/views/emptysearchview.py | 9 ++++++---
gnomemusic/widgets/albumwidget.py | 4 ++--
gnomemusic/widgets/artistalbumwidget.py | 1 -
9 files changed, 77 insertions(+), 64 deletions(-)
---
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index 6112079..be329ba 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -22,13 +22,10 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-from gi.repository import GLib, Notify
-
from gettext import gettext as _
+from gi.repository import GLib, Notify
from gnomemusic import log
-import logging
-logger = logging.getLogger(__name__)
class NotificationManager:
@@ -45,23 +42,25 @@ class NotificationManager:
self._notification.set_category('x-gnome.music')
self._notification.set_hint('action-icons', GLib.Variant('b', True))
self._notification.set_hint('resident', GLib.Variant('b', True))
- self._notification.set_hint('desktop-entry', GLib.Variant('s', 'gnome-music'))
+ self._notification.set_hint(
+ 'desktop-entry', GLib.Variant('s', 'gnome-music'))
@log
def _set_actions(self, playing):
self._notification.clear_actions()
- if (Notify.VERSION_MINOR > 7) or (Notify.VERSION_MINOR == 7 and Notify.VERSION_MICRO > 5):
- self._notification.add_action('media-skip-backward', _("Previous"),
- self._go_previous, None)
+ if (Notify.VERSION_MINOR > 7
+ or (Notify.VERSION_MINOR == 7 and Notify.VERSION_MICRO > 5)):
+ self._notification.add_action(
+ 'media-skip-backward', _("Previous"), self._go_previous, None)
if playing:
- self._notification.add_action('media-playback-pause', _("Pause"),
- self._pause, None)
+ self._notification.add_action(
+ 'media-playback-pause', _("Pause"), self._pause, None)
else:
- self._notification.add_action('media-playback-start', _("Play"),
- self._play, None)
- self._notification.add_action('media-skip-forward', _("Next"),
- self._go_next, None)
+ self._notification.add_action(
+ 'media-playback-start', _("Play"), self._play, None)
+ self._notification.add_action(
+ 'media-skip-forward', _("Next"), self._go_next, None)
@log
def _go_previous(self, notification, action, data):
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 5be6ad0..d39011b 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -106,10 +106,17 @@ class StaticPlaylists:
class Playlists(GObject.GObject):
+
__gsignals__ = {
- 'playlist-created': (GObject.SignalFlags.RUN_FIRST, None, (Grl.Media,)),
- 'playlist-deleted': (GObject.SignalFlags.RUN_FIRST, None, (Grl.Media,)),
- 'playlist-updated': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
+ 'playlist-created': (
+ GObject.SignalFlags.RUN_FIRST, None, (Grl.Media,)
+ ),
+ 'playlist-deleted': (
+ GObject.SignalFlags.RUN_FIRST, None, (Grl.Media,)
+ ),
+ 'playlist-updated': (
+ GObject.SignalFlags.RUN_FIRST, None, (int,)
+ ),
'song-added-to-playlist': (
GObject.SignalFlags.RUN_FIRST, None, (Grl.Media, Grl.Media)
),
@@ -117,6 +124,7 @@ class Playlists(GObject.GObject):
GObject.SignalFlags.RUN_FIRST, None, (Grl.Media, Grl.Media)
),
}
+
instance = None
tracker = None
@@ -141,7 +149,8 @@ class Playlists(GObject.GObject):
@log
def _on_grilo_ready(self, data=None):
- """For all static playlists: get ID, if exists; if not, create the playlist and get ID."""
+ """For all static playlists: get ID, if exists; if not, create
+ the playlist and get ID."""
def playlist_id_fetched_cb(cursor, res, playlist):
""" Called after the playlist id is fetched """
@@ -214,20 +223,22 @@ class Playlists(GObject.GObject):
""" Called when the static playlist is created """
data = obj.update_blank_finish(res)
playlist_urn = data.get_child_value(0).get_child_value(0).\
- get_child_value(0).get_child_value(1).get_string()
+ get_child_value(0).get_child_value(1).get_string()
query = Query.get_playlist_with_urn(playlist_urn)
# Start fetching the playlist
- self.tracker.query_async(query, None, playlist_queried_cb, playlist)
+ self.tracker.query_async(
+ query, None, playlist_queried_cb, playlist)
def tag_created_cb(obj, res, playlist):
""" Called when the tag is created """
creation_query = Query.create_playlist_with_tag(title, tag_text)
# Start creating the playlist itself
- self.tracker.update_blank_async(creation_query, GLib.PRIORITY_LOW,
- None, playlist_created_cb, playlist)
+ self.tracker.update_blank_async(
+ creation_query, GLib.PRIORITY_LOW, None, playlist_created_cb,
+ playlist)
# Start the playlist creation by creating the tag
self.tracker.update_blank_async(Query.create_tag(tag_text),
@@ -236,7 +247,8 @@ class Playlists(GObject.GObject):
@log
def update_static_playlist(self, playlist):
- """Given a static playlist (subclass of StaticPlaylists), updates according to its query."""
+ """Given a static playlist (subclass of StaticPlaylists),
+ updates according to its query."""
# Clear the playlist
self.clear_playlist(playlist)
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index 35a4432..317f717 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -27,15 +27,11 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-
-from gi.repository import Gtk, GObject
-
from gettext import gettext as _
-from gnomemusic.searchbar import Searchbar, DropDown
+from gi.repository import GObject, Gtk
from gnomemusic import log
-import logging
-logger = logging.getLogger(__name__)
+from gnomemusic.searchbar import Searchbar, DropDown
class ToolbarState:
@@ -65,14 +61,17 @@ class Toolbar(GObject.GObject):
self.header_bar = self._ui.get_object('header-bar')
self._search_button = self._ui.get_object('search-button')
self.dropdown = DropDown()
- self.searchbar = Searchbar(self._stack_switcher, self._search_button, self.dropdown)
+ self.searchbar = Searchbar(
+ self._stack_switcher, self._search_button, self.dropdown)
self.dropdown.initialize_filters(self.searchbar)
self._select_button = self._ui.get_object('select-button')
self._cancel_button = self._ui.get_object('done-button')
self._back_button = self._ui.get_object('back-button')
self._selection_menu = self._ui.get_object('selection-menu')
- self._selection_menu_button = self._ui.get_object('selection-menu-button')
- self._selection_menu_label = self._ui.get_object('selection-menu-button-label')
+ self._selection_menu_button = self._ui.get_object(
+ 'selection-menu-button')
+ self._selection_menu_label = self._ui.get_object(
+ 'selection-menu-button-label')
self._selection_menu_button.set_relief(Gtk.ReliefStyle.NONE)
if Gtk.get_minor_version() >= 11:
self.header_bar.remove(self._select_button)
@@ -113,7 +112,8 @@ class Toolbar(GObject.GObject):
self._select_button.hide()
self._cancel_button.show()
self.header_bar.get_style_context().add_class('selection-mode')
- self._cancel_button.get_style_context().remove_class('selection-mode')
+ self._cancel_button.get_style_context().remove_class(
+ 'selection-mode')
else:
self.header_bar.get_style_context().remove_class('selection-mode')
self._select_button.set_active(False)
@@ -130,9 +130,9 @@ class Toolbar(GObject.GObject):
view = self._stack_switcher.get_stack().get_visible_child()
view._back_button_clicked(view)
- if not ((self._window.curr_view == self._window.views[4] or
- self._window.curr_view == self._window.views[5]) and
- visible_child != self._window.curr_view._grid):
+ if not ((self._window.curr_view == self._window.views[4]
+ or self._window.curr_view == self._window.views[5])
+ and visible_child != self._window.curr_view._grid):
self.set_state(ToolbarState.MAIN)
else:
self._search_button.set_visible(True)
@@ -153,6 +153,8 @@ class Toolbar(GObject.GObject):
else:
self.reset_header_title()
- self._search_button.set_visible(self._state != ToolbarState.SEARCH_VIEW)
- self._back_button.set_visible(not self._selectionMode and self._state != ToolbarState.MAIN)
+ self._search_button.set_visible(
+ self._state != ToolbarState.SEARCH_VIEW)
+ self._back_button.set_visible(
+ not self._selectionMode and self._state != ToolbarState.MAIN)
self.header_bar.set_show_close_button(not self._selectionMode)
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 96e7156..e72590f 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -67,16 +67,11 @@ class AlbumsView(BaseView):
@log
def _setup_view(self, view_type):
- self._view = Gtk.FlowBox(homogeneous=True,
- hexpand=True,
- halign=Gtk.Align.FILL,
- valign=Gtk.Align.START,
- selection_mode=Gtk.SelectionMode.NONE,
- margin=18,
- row_spacing=12,
- column_spacing=6,
- min_children_per_line=1,
- max_children_per_line=25)
+ self._view = Gtk.FlowBox(
+ homogeneous=True, hexpand=True, halign=Gtk.Align.FILL,
+ valign=Gtk.Align.START, selection_mode=Gtk.SelectionMode.NONE,
+ margin=18, row_spacing=12, column_spacing=6,
+ min_children_per_line=1, max_children_per_line=25)
self._view.connect('child-activated', self._on_child_activated)
@@ -156,7 +151,8 @@ class AlbumsView(BaseView):
artist = utils.get_artist_name(item)
title = utils.get_media_title(item)
- builder = Gtk.Builder.new_from_resource('/org/gnome/Music/AlbumCover.ui')
+ builder = Gtk.Builder.new_from_resource(
+ '/org/gnome/Music/AlbumCover.ui')
child = Gtk.FlowBoxChild()
child.image = builder.get_object('image')
@@ -208,9 +204,11 @@ class AlbumsView(BaseView):
@log
def _on_child_toggled(self, check, pspec, child):
- if check.get_active() and not child.media_item in self.albums_selected:
+ if (check.get_active()
+ and child.media_item not in self.albums_selected):
self.albums_selected.append(child.media_item)
- elif not check.get_active() and child.media_item in self.albums_selected:
+ elif (not check.get_active()
+ and child.media_item in self.albums_selected):
self.albums_selected.remove(child.media_item)
self.update_header_from_selection(len(self.albums_selected))
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index a9781a2..237c8c5 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -130,8 +130,8 @@ class ArtistsView(BaseView):
widget = self._artists[artist.casefold()]['widget']
if widget:
- artist_widget_model = self.player.running_playlist('Artist',
- widget.artist)
+ artist_widget_model = self.player.running_playlist(
+ 'Artist', widget.artist)
artist_stack = self._artist_albums_stack
# FIXME: calling to private model
if widget._model == artist_widget_model:
@@ -149,9 +149,9 @@ class ArtistsView(BaseView):
hexpand=True)
self._artist_albums_stack.add(new_artist_albums_widget)
- artist_albums = ArtistAlbumsWidget(artist, albums, self.player,
- self._header_bar,
- self._selection_toolbar, self._window)
+ artist_albums = ArtistAlbumsWidget(
+ artist, albums, self.player, self._header_bar,
+ self._selection_toolbar, self._window)
self._artists[artist.casefold()]['widget'] = artist_albums
new_artist_albums_widget.add(artist_albums)
new_artist_albums_widget.show()
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index 2052575..c1c8024 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -96,7 +96,7 @@ class BaseView(Gtk.Stack):
self._header_bar = window.toolbar
self._selection_toolbar = window.selection_toolbar
self._header_bar._select_button.connect(
- 'toggled', self._on_header_bar_toggled)
+ 'toggled', self._on_header_bar_toggled)
self._header_bar._cancel_button.connect(
'clicked', self._on_cancel_button_clicked)
@@ -300,5 +300,5 @@ class BaseView(Gtk.Stack):
select_toolbar._add_to_playlist_button.set_sensitive(False)
select_toolbar._remove_from_playlist_button.set_sensitive(False)
self._header_bar._selection_menu_label.set_text(
- _("Click on items to select them"))
+ _("Click on items to select them"))
self.queue_draw()
diff --git a/gnomemusic/views/emptysearchview.py b/gnomemusic/views/emptysearchview.py
index 78d7bb7..91e78ac 100644
--- a/gnomemusic/views/emptysearchview.py
+++ b/gnomemusic/views/emptysearchview.py
@@ -37,7 +37,8 @@ class EmptySearchView(BaseView):
@log
def __init__(self, window, player):
- BaseView.__init__(self, 'emptysearch', None, window, Gd.MainViewType.LIST)
+ BaseView.__init__(
+ self, 'emptysearch', None, window, Gd.MainViewType.LIST)
self._artistAlbumsWidget = None
self._albumWidget = None
self.player = player
@@ -47,7 +48,8 @@ class EmptySearchView(BaseView):
widget = builder.get_object('container')
widget.set_vexpand(True)
widget.set_hexpand(True)
- widget.get_children()[1].get_children()[1].set_text(_("Try a different search"))
+ widget.get_children()[1].get_children()[1].set_text(
+ _("Try a different search"))
widget.show_all()
self._box.add(widget)
@@ -58,6 +60,7 @@ class EmptySearchView(BaseView):
self._artistAlbumsWidget.destroy()
self._artistAlbumsWidget = None
elif self.get_visible_child() == self._grid:
- self._window.views[0].set_visible_child(self._window.views[0]._grid)
+ self._window.views[0].set_visible_child(
+ self._window.views[0]._grid)
self._window.toolbar.set_state(ToolbarState.CHILD_VIEW)
self.set_visible_child(self._grid)
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 43928f0..1eac6f7 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -239,7 +239,6 @@ class AlbumWidget(Gtk.EventBox):
self._selection_mode = not self._selection_mode
self._on_selection_mode_request()
-
@log
def _song_activated(self, widget, song_widget):
if not song_widget.can_be_played:
@@ -322,7 +321,8 @@ class AlbumWidget(Gtk.EventBox):
song = playlist[_iter][5]
song_widget = song.song_widget
self._duration += song.get_duration()
- escaped_title = GLib.markup_escape_text(utils.get_media_title(song))
+ escaped_title = GLib.markup_escape_text(
+ utils.get_media_title(song))
if (song == current_song):
song_widget.now_playing_sign.show()
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 11a503d..f6d08ee 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -96,7 +96,6 @@ class ArtistAlbumWidget(Gtk.Box):
GLib.idle_add(self._update_album_art)
grilo.populate_album_songs(self._media, self._add_item)
-
def create_disc_box(self, disc_nr, disc_songs):
disc_box = DiscBox(self._model)
disc_box.set_songs(disc_songs)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]