summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2010-11-29 21:20:15 +0100
committerAnton Khirnov <anton@khirnov.net>2010-11-29 21:20:15 +0100
commitb12a662d27b700158e66943253b79c230566e8b9 (patch)
tree3dd7f04eeed31c4e6f1dc415c7a529f7b8d98230
parent071069e48c9b2c4f2aeb2db4686eec827b72b722 (diff)
song: cosmetics
-rw-r--r--nephilim/song.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/nephilim/song.py b/nephilim/song.py
index 0cf3b5c..eb5fedb 100644
--- a/nephilim/song.py
+++ b/nephilim/song.py
@@ -22,27 +22,29 @@ from string import Template
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.
- Access '?tag' to get always at least an empty string. """
-
+ """
+ Song provides a dictionary-like wrapper around song metadata.
+ Its instances are generated by MPClient, don't instantiate it
+ directly.
+ Its instances _shouldn't_ be stored, use SongRef or PlaylistEntryRef for that.
+ Access '?tag' to get always at least an empty string.
+ """
+
+ #### PUBLIC ####
def __init__(self, data = {}):
dict.__init__(self)
for key in data:
dict.__setitem__(self, key.lower(), data[key])
if not 'file' in self:
self['file'] = ''
-
def __eq__(self, other):
if not isinstance(other, Song):
return NotImplemented
return self['file'] == other['file']
-
def __ne__(self, other):
if not isinstance(other, Song):
return NotImplemented
return self['file'] != other['file']
-
def __getitem__(self, key):
key = key.lower()
try:
@@ -71,7 +73,6 @@ class Song(dict):
return os.path.dirname(self['file'])
raise KeyError
-
def __contains__(self, item):
if dict.__contains__(self, item.lower()):
return True
@@ -80,7 +81,6 @@ class Song(dict):
return True
except KeyError:
return False
-
def __nonzero__(self):
return bool(self['file'])