From 60088b7f5c672a3544edbacd88020e591017f653 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 30 Apr 2010 08:06:58 +0200 Subject: song: use '?tag' to get tag or empty string --- nephilim/song.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nephilim/song.py b/nephilim/song.py index f322fa4..fb18ed3 100644 --- a/nephilim/song.py +++ b/nephilim/song.py @@ -22,7 +22,8 @@ from common import sec2min class Song(dict): """Song provides a dictionary-like wrapper around song metadata. - Its instances _shouldn't_ be stored, use SongRef or PlaylistEntryRef for that.""" + Its instances _shouldn't_ be stored, use SongRef or PlaylistEntryRef for that. + Access '?tag' to get always at least an empty string. """ def __init__(self, data): for tag in data: @@ -45,6 +46,9 @@ class Song(dict): try: return dict.__getitem__(self, key) except KeyError: + if key and key[0] == '?': + key = key[1:] + return self[key] if key in self else '' if key == 'tracknum': try: return int(self['track']) -- cgit v1.2.3