projects
/
minwii.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Affichage des durées bien comme il faut.
[minwii.git]
/
src
/
minwii
/
logfilereader.py
diff --git
a/src/minwii/logfilereader.py
b/src/minwii/logfilereader.py
index
a08855a
..
b7f84a1
100755
(executable)
--- a/
src/minwii/logfilereader.py
+++ b/
src/minwii/logfilereader.py
@@
-6,20
+6,23
@@
$Id$
$URL$
"""
$URL$
"""
+from types import StringTypes
from widgets.playingscreen import PlayingScreenBase
from eventutils import EventDispatcher
from events import eventCodes
from synth import Synth
from musicxml import musicXml2Song
import pygame
from widgets.playingscreen import PlayingScreenBase
from eventutils import EventDispatcher
from events import eventCodes
from synth import Synth
from musicxml import musicXml2Song
import pygame
+from backwardsfilereader import BackwardsReader
SUPPORTED_FILE_HEADER = 'ENV winwii log format version : 1.0'
def inplaceread(m) :
def readinplace(self, *args, **kw) :
SUPPORTED_FILE_HEADER = 'ENV winwii log format version : 1.0'
def inplaceread(m) :
def readinplace(self, *args, **kw) :
- self.savePos()
+ pos = self.logfile.tell()
+ self.logfile.seek(0)
ret = m(self, *args, **kw)
ret = m(self, *args, **kw)
- self.
recallPos(
)
+ self.
logfile.seek(pos
)
return ret
return readinplace
return ret
return readinplace
@@
-32,23
+35,15
@@
class LogFileReader(object) :
""" logfile : chemin d'accès au fichier de log MinWii.
le format supporté est actuellement la version 1.0 uniquement.
"""
""" logfile : chemin d'accès au fichier de log MinWii.
le format supporté est actuellement la version 1.0 uniquement.
"""
- if isinstance(logfile,
str
) :
+ if isinstance(logfile,
StringTypes
) :
self.logfile = open(logfile, 'r')
else :
self.logfile = logfile
self.logfile = open(logfile, 'r')
else :
self.logfile = logfile
- self.__pos = 0
-
firstline = self.next()
assert firstline == SUPPORTED_FILE_HEADER
firstline = self.next()
assert firstline == SUPPORTED_FILE_HEADER
- def savePos(self) :
- self.__pos = self.logfile.tell()
- self.logfile.seek(0)
-
- def recallPos(self) :
- self.logfile.seek(self.__pos)
-
+
@inplaceread
def getSongFile(self) :
"retourne le chemin d'accès au fichier musicxml de la chanson"
@inplaceread
def getSongFile(self) :
"retourne le chemin d'accès au fichier musicxml de la chanson"
@@
-113,6
+108,16
@@
class LogFileReader(object) :
firstTicks = int(l.split(None, 2)[1])
return firstTicks
firstTicks = int(l.split(None, 2)[1])
return firstTicks
+ @inplaceread
+ def getLastEventTicks(self) :
+ "retourne le timecode du dernier événement (entier)"
+ for l in self.getBackwardLineIterator() :
+ if l.startswith('EVT ') :
+ break
+
+ lastTicks = int(l.split(None, 2)[1])
+ return lastTicks
+
def __del__(self) :
self.logfile.close()
def __del__(self) :
self.logfile.close()
@@
-146,6
+151,14
@@
class LogFileReader(object) :
ticks, eventName = l.split(None, 3)[1:]
ticks = int(ticks)
yield ticks, eventName, ''
ticks, eventName = l.split(None, 3)[1:]
ticks = int(ticks)
yield ticks, eventName, ''
+
+ def getBackwardLineIterator(self) :
+ br = BackwardsReader(self.logfile, BLKSIZE=128)
+ line = br.readline()
+ while line :
+ yield line.strip()
+ line = br.readline()
+
class LogFilePlayer(PlayingScreenBase) :
class LogFilePlayer(PlayingScreenBase) :