[gnome-music/wip/jfelder/tracker3-rebased: 19/46] utils: Optional return of empty string for year




commit 616b5a78f9948ea39eb190088f3e698327a330e6
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Jan 16 15:40:48 2020 +0100

    utils: Optional return of empty string for year

 gnomemusic/corealbum.py | 2 +-
 gnomemusic/utils.py     | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index d279e811..417b2714 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -69,7 +69,7 @@ class CoreAlbum(GObject.GObject):
         self.props.composer = media.get_composer()
         self.props.title = utils.get_media_title(media)
         self.props.url = media.get_url()
-        self.props.year = utils.get_media_year(media)
+        self.props.year = utils.get_media_year(media, True)
 
     def _get_album_model(self):
         disc_model = Gio.ListStore()
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index 5be7e8ca..4aafb27f 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -135,17 +135,20 @@ def get_media_title(item):
     return title
 
 
-def get_media_year(item):
+def get_media_year(item, fill_empty=False):
     """Returns the year when the media was created.
 
     :param Grl.Media item: A Grilo Media object
-    :return: The creation year or '----' if not defined
+    :param bool fill_empty: If True return '----' if date not defined
+    :return: The creation year if defined
     :rtype: str
     """
     date = item.get_creation_date()
 
     if not date:
-        return "----"
+        if fill_empty is True:
+            return "----"
+        return ""
 
     return str(date.get_year())
 


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