[gnome-music] Add short repr for objects to simplify logging



commit a72132283eee7a6d55bcedfb4628041565bffa08
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Wed Aug 5 10:35:17 2015 +0200

    Add short repr for objects to simplify logging

 gnomemusic/albumArtCache.py |    3 +++
 gnomemusic/application.py   |    4 ++++
 gnomemusic/grilo.py         |    3 +++
 gnomemusic/mpris.py         |    3 +++
 gnomemusic/notification.py  |    4 ++++
 gnomemusic/player.py        |    9 +++++++++
 gnomemusic/playlists.py     |    7 +++++++
 gnomemusic/query.py         |    3 +++
 gnomemusic/searchbar.py     |   18 ++++++++++++++++++
 gnomemusic/toolbar.py       |    3 +++
 gnomemusic/view.py          |   33 +++++++++++++++++++++++++++++++++
 gnomemusic/widgets.py       |   23 +++++++++++++++++++++++
 gnomemusic/window.py        |    3 +++
 13 files changed, 116 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index 474a208..d3a4a42 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -90,6 +90,9 @@ class AlbumArtCache(GObject.GObject):
     default_icon_width = 256
     default_icon_height = 256
 
+    def __repr__(self):
+        return '<AlbumArt>'
+
     @classmethod
     def get_default(self):
         if not self.instance:
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index bb7a45c..7e8b061 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -43,6 +43,10 @@ logger = logging.getLogger(__name__)
 
 
 class Application(Gtk.Application):
+
+    def __repr__(self):
+        return '<Application>'
+
     @log
     def __init__(self):
         Gtk.Application.__init__(self,
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 6a9eb4e..a810628 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -62,6 +62,9 @@ class Grilo(GObject.GObject):
     CHANGED_MEDIA_MAX_ITEMS = 500
     CHANGED_MEDIA_SIGNAL_TIMEOUT = 2000
 
+    def __repr__(self):
+        return '<Grilo>'
+
     @log
     def __init__(self):
         GObject.GObject.__init__(self)
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 32d0342..24d4e3d 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -47,6 +47,9 @@ class MediaPlayer2Service(dbus.service.Object):
     MEDIA_PLAYER2_TRACKLIST_IFACE = 'org.mpris.MediaPlayer2.TrackList'
     MEDIA_PLAYER2_PLAYLISTS_IFACE = 'org.mpris.MediaPlayer2.Playlists'
 
+    def __repr__(self):
+        return '<MediaPlayer2Service>'
+
     def __init__(self, app):
         DBusGMainLoop(set_as_default=True)
         name = dbus.service.BusName('org.mpris.MediaPlayer2.GnomeMusic', dbus.SessionBus())
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index e499313..8481e2a 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -36,6 +36,10 @@ IMAGE_SIZE = 125
 
 
 class NotificationManager:
+
+    def __repr__(self):
+        return '<NotificationManager>'
+
     @log
     def __init__(self, player):
         self._player = player
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 0a3b082..2995723 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -95,6 +95,9 @@ class Player(GObject.GObject):
         'thumbnail-updated': (GObject.SignalFlags.RUN_FIRST, None, (str,)),
     }
 
+    def __repr__(self):
+        return '<Player>'
+
     @log
     def __init__(self, parent_window):
         GObject.GObject.__init__(self)
@@ -1068,6 +1071,9 @@ class Player(GObject.GObject):
 
 class MissingCodecsDialog(Gtk.MessageDialog):
 
+    def __repr__(self):
+        return '<MissingCodecsDialog>'
+
     @log
     def __init__(self, parent_window, install_helper_name):
         Gtk.MessageDialog.__init__(self,
@@ -1102,6 +1108,9 @@ class MissingCodecsDialog(Gtk.MessageDialog):
 
 class SelectionToolbar():
 
+    def __repr__(self):
+        return '<SelectionToolbar>'
+
     @log
     def __init__(self):
         self._ui = Gtk.Builder()
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 9249309..0d6460e 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -41,6 +41,10 @@ logger = logging.getLogger(__name__)
 
 
 class StaticPlaylists:
+
+    def __repr__(self):
+        return '<StaticPlaylists>'
+
     class MostPlayed:
         ID = None
         QUERY = Query.get_most_played_songs()
@@ -97,6 +101,9 @@ class Playlists(GObject.GObject):
     instance = None
     tracker = None
 
+    def __repr__(self):
+        return '<Playlists>'
+
     @classmethod
     def get_default(self, tracker=None):
         if self.instance:
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index 0c32305..251453f 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -56,6 +56,9 @@ class Query():
     except TypeError:
         logger.warn("XDG user dirs are not set")
 
+    def __repr__(self):
+        return '<Query>'
+
     @staticmethod
     def order_by_statement(attr):
         """Returns a SPARQL ORDER BY statement sorting by the given attribute, ignoring
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index 443f54e..2d0ad24 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -40,6 +40,10 @@ class BaseModelColumns():
 
 
 class BaseManager:
+
+    def __repr__(self):
+        return '<BaseManager>'
+
     @log
     def __init__(self, id, label, entry):
         self.id = id
@@ -94,6 +98,9 @@ class BaseManager:
 
 class SourceManager(BaseManager):
 
+    def __repr__(self):
+        return '<SourceManager>'
+
     @log
     def __init__(self, id, label, entry):
         super(SourceManager, self).__init__(id, label, entry)
@@ -124,6 +131,10 @@ class SourceManager(BaseManager):
 
 
 class FilterView():
+
+    def __repr__(self):
+        return '<FilterView>'
+
     @log
     def __init__(self, manager, dropdown):
         self.manager = manager
@@ -186,6 +197,10 @@ class FilterView():
 
 
 class DropDown(Gtk.Revealer):
+
+    def __repr__(self):
+        return '<DropDown>'
+
     @log
     def __init__(self):
         Gtk.Revealer.__init__(self, halign=Gtk.Align.CENTER, valign=Gtk.Align.START)
@@ -227,6 +242,9 @@ class DropDown(Gtk.Revealer):
 
 class Searchbar(Gtk.Revealer):
 
+    def __repr__(self):
+        return '<Searchbar>'
+
     @log
     def __init__(self, stack_switcher, search_button, dropdown):
         Gtk.Revealer.__init__(self)
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index 462d487..992ba6f 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -50,6 +50,9 @@ class Toolbar(GObject.GObject):
     }
     _selectionMode = False
 
+    def __repr__(self):
+        return '<Toolbar>'
+
     @log
     def __init__(self):
         GObject.GObject.__init__(self)
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 9d6a0d6..b37175b 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -59,6 +59,9 @@ class ViewContainer(Gtk.Stack):
     nowPlayingIconName = 'media-playback-start-symbolic'
     errorIconName = 'dialog-error-symbolic'
 
+    def __repr__(self):
+        return '<ViewContainer>'
+
     @log
     def __init__(self, name, title, window, view_type, use_sidebar=False, sidebar=None):
         Gtk.Stack.__init__(self,
@@ -256,6 +259,10 @@ class ViewContainer(Gtk.Stack):
 
 # Class for the Empty View
 class Empty(Gtk.Stack):
+
+    def __repr__(self):
+        return '<EmptyView>'
+
     @log
     def __init__(self, window, player):
         Gtk.Stack.__init__(self,
@@ -275,6 +282,10 @@ class Empty(Gtk.Stack):
 
 # Class for the Initial State
 class InitialState(Empty):
+
+    def __repr__(self):
+        return '<InitialState>'
+
     @log
     def __init__(self, window, player):
         Empty.__init__(self, window, player)
@@ -294,6 +305,10 @@ class InitialState(Empty):
 
 
 class Albums(ViewContainer):
+
+    def __repr__(self):
+        return '<Albums>'
+
     @log
     def __init__(self, window, player):
         ViewContainer.__init__(self, 'albums', _("Albums"), window, Gd.MainViewType.ICON)
@@ -385,6 +400,10 @@ class Albums(ViewContainer):
 
 
 class Songs(ViewContainer):
+
+    def __repr__(self):
+        return '<Songs>'
+
     @log
     def __init__(self, window, player):
         ViewContainer.__init__(self, 'songs', _("Songs"), window, Gd.MainViewType.LIST)
@@ -583,6 +602,10 @@ class Songs(ViewContainer):
 
 
 class Artists (ViewContainer):
+
+    def __repr__(self):
+        return '<Artists>'
+
     @log
     def __init__(self, window, player):
         ViewContainer.__init__(self, 'artists', _("Artists"),
@@ -787,6 +810,9 @@ class Playlist(ViewContainer):
         'playlist-songs-loaded': (GObject.SignalFlags.RUN_FIRST, None, ()),
     }
 
+    def __repr__(self):
+        return '<Playlist>'
+
     @log
     def __init__(self, window, player):
         self.playlists_sidebar = Gd.MainView(
@@ -1285,6 +1311,10 @@ class Playlist(ViewContainer):
 
 
 class EmptySearch(ViewContainer):
+
+    def __repr__(self):
+        return '<EmptySearch>'
+
     @log
     def __init__(self, window, player):
         ViewContainer.__init__(self, 'emptysearch', None, window, Gd.MainViewType.LIST)
@@ -1314,6 +1344,9 @@ class Search(ViewContainer):
         'no-music-found': (GObject.SignalFlags.RUN_FIRST, None, ())
     }
 
+    def __repr__(self):
+        return '<Search>'
+
     @log
     def __init__(self, window, player):
         ViewContainer.__init__(self, 'search', None, window, Gd.MainViewType.LIST)
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 22de7ae..63db254 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -57,6 +57,10 @@ playlists = Playlists.get_default()
 
 
 class StarHandler():
+
+    def __repr__(self):
+        return '<StarHandler>'
+
     @log
     def __init__(self, parent, star_index):
         self.star_index = star_index
@@ -95,6 +99,9 @@ class AlbumWidget(Gtk.EventBox):
     loadingIcon = ALBUM_ART_CACHE.get_default_icon(256, 256, True)
     noArtworkIcon = ALBUM_ART_CACHE.get_default_icon(256, 256, False)
 
+    def __repr__(self):
+        return '<AlbumWidget>'
+
     @log
     def __init__(self, player, parentview):
         Gtk.EventBox.__init__(self)
@@ -361,6 +368,9 @@ class AlbumWidget(Gtk.EventBox):
 
 class ArtistAlbums(Gtk.Box):
 
+    def __repr__(self):
+        return '<ArtistAlbums>'
+
     @log
     def __init__(self, artist, albums, player,
                  header_bar, selection_toolbar, window, selectionModeAllowed=False):
@@ -519,6 +529,9 @@ class ArtistAlbums(Gtk.Box):
 
 class AllArtistsAlbums(ArtistAlbums):
 
+    def __repr__(self):
+        return '<AllArtistsAlbums>'
+
     @log
     def __init__(self, player, header_bar, selection_toolbar, selectionModeAllowed=False):
         ArtistAlbums.__init__(self, _("All Artists"), [], player,
@@ -551,6 +564,9 @@ class ArtistAlbumWidget(Gtk.Box):
     loadingIcon = AlbumArtCache.get_default().get_default_icon(128, 128, True)
     noArtworkIcon = ALBUM_ART_CACHE.get_default_icon(128, 128, False)
 
+    def __repr__(self):
+        return '<ArtistAlbumWidget>'
+
     @log
     def __init__(self, artist, album, player, model, header_bar, selectionModeAllowed):
         Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
@@ -704,6 +720,10 @@ class ArtistAlbumWidget(Gtk.Box):
 
 
 class PlaylistDialog():
+
+    def __repr__(self):
+        return '<PlaylistDialog>'
+
     @log
     def __init__(self, parent):
         self.ui = Gtk.Builder()
@@ -833,6 +853,9 @@ class CellRendererClickablePixbuf(Gtk.CellRendererPixbuf):
     starIcon = 'starred-symbolic'
     nonStarIcon = 'non-starred-symbolic'
 
+    def __repr__(self):
+        return '<CellRendererClickablePixbuf>'
+
     def __init__(self, view, hidden=False, *args, **kwargs):
         Gtk.CellRendererPixbuf.__init__(self, *args, **kwargs)
         self.set_property('mode', Gtk.CellRendererMode.ACTIVATABLE)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index d8727c8..ca4310e 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -52,6 +52,9 @@ playlist = Playlists.get_default()
 
 class Window(Gtk.ApplicationWindow):
 
+    def __repr__(self):
+        return '<Window>'
+
     @log
     def __init__(self, app):
         Gtk.ApplicationWindow.__init__(self,



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