summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2010-04-30 08:06:58 +0200
committerAnton Khirnov <wyskas@gmail.com>2010-04-30 08:06:58 +0200
commit60088b7f5c672a3544edbacd88020e591017f653 (patch)
tree6eb6f649cb6f8ecbbbb49b57d1dce07280c42c08
parentc6e0c356b0daaa51d3fcd3da4b89c89eee907b22 (diff)
song: use '?tag' to get tag or empty string
-rw-r--r--nephilim/song.py6
1 files changed, 5 insertions, 1 deletions
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'])