[gnome-music/wip/gbsneto/playlist-improvements: 1/3] playlists: add base class for static playlists



commit e5e2b438756130056aa39700d824571ff763d25c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 18 10:48:02 2016 -0200

    playlists: add base class for static playlists
    
    Since the all share the same fields internally, it makes
    sense to have the static playlists descend from the same
    class.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773192

 gnomemusic/playlists.py |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index be23590..38c3924 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -40,37 +40,41 @@ import logging
 logger = logging.getLogger(__name__)
 
 
+class Playlist:
+    """ Base class of static and intelligent playlists """
+    ID = None
+    QUERY = None
+    FILTER = None
+    TAG_TEXT = ""
+    TITLE = ""
+
+
 class StaticPlaylists:
 
     def __repr__(self):
         return '<StaticPlaylists>'
 
-    class MostPlayed:
-        ID = None
+    class MostPlayed(Playlist):
         TAG_TEXT = "MOST_PLAYED"
         # TRANSLATORS: this is a playlist name
         TITLE = _("Most Played")
 
-    class NeverPlayed:
-        ID = None
+    class NeverPlayed(Playlist):
         TAG_TEXT = "NEVER_PLAYED"
         # TRANSLATORS: this is a playlist name
         TITLE = _("Never Played")
 
-    class RecentlyPlayed:
-        ID = None
+    class RecentlyPlayed(Playlist):
         TAG_TEXT = "RECENTLY_PLAYED"
         # TRANSLATORS: this is a playlist name
         TITLE = _("Recently Played")
 
-    class RecentlyAdded:
-        ID = None
+    class RecentlyAdded(Playlist):
         TAG_TEXT = "RECENTLY_ADDED"
         # TRANSLATORS: this is a playlist name
         TITLE = _("Recently Added")
 
-    class Favorites:
-        ID = None
+    class Favorites(Playlist):
         TAG_TEXT = "FAVORITES"
         # TRANSLATORS: this is a playlist name
         TITLE = _("Favorite Songs")


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