From: pin Date: Fri, 11 Jun 2010 10:07:32 +0000 (+0000) Subject: Affichage du titre de la chanson dans le browser. X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/dec65f326821db9871750e207cdd5c430632f3b3 Affichage du titre de la chanson dans le browser. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@228 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/minwii/widgets/songfilebrowser.py b/src/minwii/widgets/songfilebrowser.py index 973f9ab..99f81da 100755 --- a/src/minwii/widgets/songfilebrowser.py +++ b/src/minwii/widgets/songfilebrowser.py @@ -8,6 +8,7 @@ $URL$ from pgu.gui import FileDialog import os +from xml.etree import ElementTree class FileOpenDialog(FileDialog): @@ -28,24 +29,37 @@ class FileOpenDialog(FileDialog): files = [] try: for i in os.listdir(self.curdir): + if i.startswith('.') : continue if os.path.isdir(os.path.join(self.curdir, i)): dirs.append(i) else: files.append(i) except: - self.input_file.value = "Opps! no access" - #if '..' not in dirs: dirs.append('..') + self.input_file.value = "Dossier innacessible !" + dirs.sort() - dirs = ['..'] + dirs + dirs.insert(0, '..') files.sort() for i in dirs: - if i.startswith('.') and i != '..' : - continue self.list.add(i, image=self.dir_img, value=i) for i in files: - if i.startswith('.') or (not i.endswith('.xml')) : + if not i.endswith('.xml') : continue - self.list.add(i,value=i) - + filepath = os.path.join(self.curdir, i) + self.list.add(FileOpenDialog.getSongTitle(filepath), value=i) + self.list.set_vertical_scroll(0) - + + @staticmethod + def getSongTitle(file) : + it = ElementTree.iterparse(file, ['start', 'end']) + creditFound = False + + for evt, el in it : + if el.tag == 'credit' : + creditFound = True + if el.tag == 'credit-words' and creditFound: + return el.text.encode('iso-8859-1') + if el.tag == 'part-list' : + # plus de chance de trouver un titre + return os.path.basename(file) \ No newline at end of file