[gnome-music/wip/mschraal/pydeprecation: 3/3] Use Python 3 style super calls
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/pydeprecation: 3/3] Use Python 3 style super calls
- Date: Wed, 27 Dec 2017 14:17:08 +0000 (UTC)
commit c9e34c89bc6dc38682c8fe8ee5e7a0056acc1356
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Dec 27 14:54:54 2017 +0100
Use Python 3 style super calls
The codebase was using mixed style (Python 2 & 3) superclass calls,
replace it with Python 3 super() calls only.
gnomemusic/albumartcache.py | 6 ++++--
gnomemusic/application.py | 6 ++++--
gnomemusic/grilo.py | 3 ++-
gnomemusic/player.py | 14 ++++++--------
gnomemusic/playlists.py | 3 ++-
gnomemusic/searchbar.py | 10 ++++++----
gnomemusic/toolbar.py | 3 ++-
gnomemusic/views/albumsview.py | 2 +-
gnomemusic/views/artistsview.py | 4 ++--
gnomemusic/views/baseview.py | 4 ++--
gnomemusic/views/emptysearchview.py | 4 ++--
gnomemusic/views/emptyview.py | 4 ++--
gnomemusic/views/initialstateview.py | 2 +-
gnomemusic/views/searchview.py | 2 +-
gnomemusic/views/songsview.py | 3 +--
gnomemusic/widgets/albumwidget.py | 2 +-
gnomemusic/widgets/artistalbumswidget.py | 2 +-
gnomemusic/widgets/artistalbumwidget.py | 2 +-
gnomemusic/widgets/disclistboxwidget.py | 4 ++--
gnomemusic/window.py | 5 ++---
20 files changed, 45 insertions(+), 40 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 17a6965..f5e0cdb 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -165,7 +165,8 @@ class DefaultIcon(GObject.GObject):
@log
def __init__(self, scale=1):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self._scale = scale
@log
@@ -236,7 +237,8 @@ class AlbumArtCache(GObject.GObject):
@log
def __init__(self, scale=1):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self._scale = scale
self.cache_dir = os.path.join(GLib.get_user_cache_dir(), 'media-art')
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index 2fa8a1d..00ec429 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -48,8 +48,10 @@ class Application(Gtk.Application):
@log
def __init__(self):
- Gtk.Application.__init__(self, application_id='org.gnome.Music',
- flags=Gio.ApplicationFlags.FLAGS_NONE)
+ super().__init__(
+ application_id='org.gnome.Music',
+ flags=Gio.ApplicationFlags.FLAGS_NONE)
+
GLib.set_application_name(_("Music"))
GLib.set_prgname('gnome-music')
GLib.setenv("PULSE_PROP_media.role", "music", True)
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 21d6f02..55cd55c 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -80,7 +80,8 @@ class Grilo(GObject.GObject):
@log
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self.playlist_path = GLib.build_filenamev([GLib.get_user_data_dir(),
"gnome-music", "playlists"])
if not (GLib.file_test(self.playlist_path, GLib.FileTest.IS_DIR)):
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 8ce9153..a5cfff3 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -101,7 +101,8 @@ class Player(GObject.GObject):
@log
def __init__(self, parent_window):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self._parent_window = parent_window
self.playlist = None
self.playlistType = None
@@ -1158,13 +1159,10 @@ class MissingCodecsDialog(Gtk.MessageDialog):
@log
def __init__(self, parent_window, install_helper_name):
- Gtk.MessageDialog.__init__(self,
- transient_for=parent_window,
- modal=True,
- destroy_with_parent=True,
- message_type=Gtk.MessageType.ERROR,
- buttons=Gtk.ButtonsType.CANCEL,
- text=_("Unable to play the file"))
+ super().__init__(
+ transient_for=parent_window, modal=True, destroy_with_parent=True,
+ message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CANCEL,
+ text=_("Unable to play the file"))
# TRANSLATORS: this is a button to launch a codec installer.
# %s will be replaced with the software installer's name, e.g.
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 3952255..ed32717 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -144,7 +144,8 @@ class Playlists(GObject.GObject):
@log
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self.tracker = TrackerWrapper().tracker
self._static_playlists = StaticPlaylists()
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index b62dc92..43fa601 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -104,8 +104,9 @@ class SourceManager(BaseManager):
return '<SourceManager>'
@log
- def __init__(self, id, label, entry):
- super(SourceManager, self).__init__(id, label, entry)
+ def __init__(self, id_, label, entry):
+ super().__init__(id_, label, entry)
+
self.values.append(['', '', self.label])
self.values.append(['all', _("All"), ""])
self.values.append(['grl-tracker-source', _("Local"), ''])
@@ -207,7 +208,7 @@ class DropDown(Gtk.Revealer):
@log
def __init__(self):
- Gtk.Revealer.__init__(self, halign=Gtk.Align.CENTER, valign=Gtk.Align.START)
+ super().__init__(halign=Gtk.Align.CENTER, valign=Gtk.Align.START)
self._grid = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL)
@@ -251,7 +252,8 @@ class Searchbar(Gtk.SearchBar):
@log
def __init__(self, stack_switcher, search_button, dropdown):
- Gtk.Revealer.__init__(self)
+ super().__init__()
+
self.timeout = None
self.stack_switcher = stack_switcher
self._search_button = search_button
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index 445a0e2..dd3709e 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -52,7 +52,8 @@ class Toolbar(GObject.GObject):
@log
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
+
self._stack_switcher = Gtk.StackSwitcher(can_focus=False,
halign="center")
self._stack_switcher.show()
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 8cbf6be..5288a97 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -41,7 +41,7 @@ class AlbumsView(BaseView):
@log
def __init__(self, window, player):
- BaseView.__init__(self, 'albums', _("Albums"), window, None)
+ super().__init__('albums', _("Albums"), window, None)
self._album_widget = AlbumWidget(player, self)
self.player = player
self.add(self._album_widget)
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 237c8c5..2154fd8 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -52,8 +52,8 @@ class ArtistsView(BaseView):
:param GtkWidget window: The main window
:param player: The main player object
"""
- BaseView.__init__(self, 'artists', _("Artists"), window,
- Gd.MainViewType.LIST, True)
+ super().__init__(
+ 'artists', _("Artists"), window, Gd.MainViewType.LIST, True)
self.player = player
self._artists = {}
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index c1c8024..42e19a0 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -54,8 +54,8 @@ class BaseView(Gtk.Stack):
:param sidebar: The sidebar object (Default: Gtk.Box)
"""
- Gtk.Stack.__init__(self,
- transition_type=Gtk.StackTransitionType.CROSSFADE)
+ super().__init__(transition_type=Gtk.StackTransitionType.CROSSFADE)
+
self._grid = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL)
self._offset = 0
self.model = Gtk.ListStore(
diff --git a/gnomemusic/views/emptysearchview.py b/gnomemusic/views/emptysearchview.py
index bacf5dc..0b49f8b 100644
--- a/gnomemusic/views/emptysearchview.py
+++ b/gnomemusic/views/emptysearchview.py
@@ -37,8 +37,8 @@ class EmptySearchView(BaseView):
@log
def __init__(self, window, player):
- BaseView.__init__(
- self, 'emptysearch', None, window, Gd.MainViewType.LIST)
+ super().__init__('emptysearch', None, window, Gd.MainViewType.LIST)
+
self._artist_albums_widget = None
self.player = player
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index 641c4e0..85d48c9 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -36,8 +36,8 @@ class EmptyView(Gtk.Stack):
@log
def __init__(self, window, player):
- Gtk.Stack.__init__(self,
- transition_type=Gtk.StackTransitionType.CROSSFADE)
+ super().__init__(transition_type=Gtk.StackTransitionType.CROSSFADE)
+
self.builder = Gtk.Builder()
self.builder.add_from_resource('/org/gnome/Music/NoMusic.ui')
widget = self.builder.get_object('container')
diff --git a/gnomemusic/views/initialstateview.py b/gnomemusic/views/initialstateview.py
index 6e2f9ab..3c1d02f 100644
--- a/gnomemusic/views/initialstateview.py
+++ b/gnomemusic/views/initialstateview.py
@@ -36,7 +36,7 @@ class InitialStateView(EmptyView):
@log
def __init__(self, window, player):
- EmptyView.__init__(self, window, player)
+ super().__init__(window, player)
# Update image
icon = self.builder.get_object('icon')
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 91a4107..6c2284d 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -51,7 +51,7 @@ class SearchView(BaseView):
@log
def __init__(self, window, player):
- BaseView.__init__(self, 'search', None, window, Gd.MainViewType.LIST)
+ super().__init__('search', None, window, Gd.MainViewType.LIST)
scale = self.get_scale_factor()
loading_icon_surface = DefaultIcon(scale).get(
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index 9a2b5ab..623c753 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -52,8 +52,7 @@ class SongsView(BaseView):
:param GtkWidget window: The main window
:param player: The main player object
"""
- BaseView.__init__(self, 'songs', _("Songs"),
- window, Gd.MainViewType.LIST)
+ super().__init__('songs', _("Songs"), window, Gd.MainViewType.LIST)
self._offset = 0
self._iter_to_clean = None
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 1eac6f7..9df8b5a 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -51,7 +51,7 @@ class AlbumWidget(Gtk.EventBox):
:param player: The player object
:param parent_view: The view this widget is part of
"""
- Gtk.EventBox.__init__(self)
+ super().__init__()
self._songs = []
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index ea0beeb..c870b2b 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -48,7 +48,7 @@ class ArtistAlbumsWidget(Gtk.Box):
@log
def __init__(self, artist, albums, player, header_bar, selection_toolbar,
window, selection_mode_allowed=False):
- Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
+ super().__init__(orientation=Gtk.Orientation.VERTICAL)
self._player = player
self.artist = artist
self._window = window
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index f6d08ee..1917694 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -44,7 +44,7 @@ class ArtistAlbumWidget(Gtk.Box):
def __init__(self, media, player, model, header_bar,
selection_mode_allowed, size_group=None,
cover_size_group=None):
- super().__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
+ super().__init__(orientation=Gtk.Orientation.HORIZONTAL)
self._size_group = size_group
self._cover_size_group = cover_size_group
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index b012e62..f51dfd2 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -40,7 +40,7 @@ class StarImage(Gtk.Image):
@log
def __init__(self):
- super().__init__(self)
+ super().__init__()
self._favorite = False
@@ -104,7 +104,7 @@ class DiscSongsFlowBox(Gtk.FlowBox):
:param int columns: The number of columns the widget uses
"""
- super().__init__(self)
+ super().__init__()
super().set_selection_mode(Gtk.SelectionMode.NONE)
self._columns = columns
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 12addd8..9693b72 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -63,9 +63,8 @@ class Window(Gtk.ApplicationWindow):
@log
def __init__(self, app):
- Gtk.ApplicationWindow.__init__(self,
- application=app,
- title=_("Music"))
+ super().__init__(application=app, title=_("Music"))
+
self.connect('focus-in-event', self._windows_focus_cb)
self.settings = Gio.Settings.new('org.gnome.Music')
self.add_action(self.settings.create_action('repeat'))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]