From 6ac0f3c83c7f2b916038acfed564ba6c7fe8e9f4 Mon Sep 17 00:00:00 2001 From: pin Date: Wed, 7 Jul 2010 16:18:51 +0000 Subject: [PATCH] =?utf8?q?Ajout=20d'un=20it=C3=A9rateur=20=C3=A0=20rebrous?= =?utf8?q?se-poil=20dans=20les=20lignes=20du=20fichier=20de=20log.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@277 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/logfilereader.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/minwii/logfilereader.py b/src/minwii/logfilereader.py index 44c3611..648cdee 100755 --- a/src/minwii/logfilereader.py +++ b/src/minwii/logfilereader.py @@ -12,6 +12,7 @@ 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' @@ -106,6 +107,16 @@ class LogFileReader(object) : 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() @@ -139,6 +150,14 @@ class LogFileReader(object) : 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) : -- 2.20.1