[gnome-music/wip/jfelder/songeditor-gtk4: 1/32] utils: Optional return of empty string for year




commit 7fa402f88b140880508008e6921902b315321b6c
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 27008184e..a0b6af714 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -73,7 +73,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 0e46980b2..5d0cb6717 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -139,17 +139,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 published.
 
     :param Grl.Media item: A Grilo Media object
-    :return: The publication year or '----' if not defined
+    :param bool fill_empty: If True and date is defined return '----'
+    :return: The publication year if defined
     :rtype: str
     """
     date = item.get_publication_date()
 
     if not date:
-        return "----"
+        if fill_empty:
+            return "----"
+        return ""
 
     return str(date.get_year())
 


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