1
2 """Analyze Line for Time"""
3
4 import re
5 from sys import stdout
6
7 from LogLineAnalyzer import LogLineAnalyzer
8
10 """Parses the line for the current time and makes it available to
11 the parent analyzer (who makes it available to all of his
12 children). This side-effect is important for all the other
13 line-analyzers that need the time"""
14
15 timeRegExp="^Time = (.+)$"
16
18 """
19 Constructs the analyzer
20
21 @param progress: whether to print the time on the console
22 """
23 LogLineAnalyzer.__init__(self)
24 self.exp=re.compile(self.timeRegExp)
25 self.progress=progress
26
28 m=self.exp.match(line)
29 if m!=None:
30 try:
31 self.notify(float(m.group(1)))
32 if self.progress:
33 print "\r t = %10g" % self.parent.time,
34 stdout.flush()
35
36 except ValueError:
37 pass
38