summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2010-08-12 09:01:20 +0200
committerAnton Khirnov <wyskas@gmail.com>2010-08-12 19:31:34 +0200
commit6bd954986e9b13b31f7f3c2e41f06c9459419eea (patch)
tree2190d2897be885b0caf57278cbaee13421f255fb
parent067b31a32597ec146c0f383028d3edb0f746e5dc (diff)
song: make keys case-insensitive
-rw-r--r--nephilim/song.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/nephilim/song.py b/nephilim/song.py
index cbe22d5..0eef97b 100644
--- a/nephilim/song.py
+++ b/nephilim/song.py
@@ -26,12 +26,12 @@ class Song(dict):
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:
- if isinstance(data[tag], list):
- data[tag] = ','.join(data[tag])
-
- dict.__init__(self, data)
+ 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):
@@ -44,6 +44,7 @@ class Song(dict):
return self['file'] != other['file']
def __getitem__(self, key):
+ key = key.lower()
try:
return dict.__getitem__(self, key)
except KeyError:
@@ -72,7 +73,7 @@ class Song(dict):
raise KeyError
def __contains__(self, item):
- if dict.__contains__(self, item):
+ if dict.__contains__(self, item.lower()):
return True
try:
self[item]