File: song.py

package info (click to toggle)
mc-foo 0.0.13
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 268 kB
  • ctags: 532
  • sloc: python: 1,967; makefile: 6
file content (18 lines) | stat: -rw-r--r-- 762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import UserDict

class GuiSong(UserDict.UserDict):
    def __init__(self, data={}):
        UserDict.UserDict.__init__(self, data)

    def __str__(self):
        if self.data.has_key('comment') \
           and self.data['comment'].has_key('ARTIST') \
           and self.data['comment'].has_key('TITLE') \
           and filter(lambda x: x!="", self.data['comment']['ARTIST'])!=[] \
           and filter(lambda x: x!="", self.data['comment']['TITLE'])!=[]:
            return str(filter(lambda x: x!="", self.data['comment']['ARTIST'])[0]) \
                   +': '+str(filter(lambda x: x!="", self.data['comment']['TITLE'])[0])
        elif self.data.has_key('filename'):
            return self.data['filename']
        else:
            return repr(self)