summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fd41523)
from minwii.globals import PLAYING_MODES
from statlib import stats
from datetime import timedelta
from minwii.globals import PLAYING_MODES
from statlib import stats
from datetime import timedelta
+from xml.etree import ElementTree
+import os.path
PLAYING_MODES = dict(PLAYING_MODES)
PLAYING_MODES = dict(PLAYING_MODES)
try :
self.mode = mode = self.getMode()
results.append(('Mode de jeu', PLAYING_MODES.get(mode, mode)))
try :
self.mode = mode = self.getMode()
results.append(('Mode de jeu', PLAYING_MODES.get(mode, mode)))
+
+ self.songTitle = LogFileAnalyser.getSongTitle(self.getSongFile())
+ results.append(('Chanson', self.songTitle))
+
for name in self.POSSIBLE_ANALYSES[mode] :
meth = getattr(self, name)
results.append((meth.__doc__, meth()))
for name in self.POSSIBLE_ANALYSES[mode] :
meth = getattr(self, name)
results.append((meth.__doc__, meth()))
+ @staticmethod
+ def getSongTitle(file) :
+ if os.path.exists(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
+ if el.tag == 'part-list' :
+ # plus de chance de trouver un titre
+ return os.path.basename(file)
+ else :
+ return os.path.basename(file)
+
def _toTimeDelta(self, milliseconds) :
duration = milliseconds / 1000.
duration = int(round(duration, 0))
def _toTimeDelta(self, milliseconds) :
duration = milliseconds / 1000.
duration = int(round(duration, 0))
f = self.logfile
f.seek(0)
before = f.readline()
f = self.logfile
f.seek(0)
before = f.readline()
+ line = f.readline()
+ while line.startswith('METADATA ') :
+ line = f.readline()
+ after = line + f.read()
lines = []
for name, value in metadata :
lines = []
for name, value in metadata :