1
2 """Analyze Line for Time"""
3
4 import re
5 from sys import stdout
6
7 from LogLineAnalyzer import LogLineAnalyzer
8
9 from PyFoam import configuration as conf
10
12 """Parses the line for the current time and makes it available to
13 the parent analyzer (who makes it available to all of his
14 children). This side-effect is important for all the other
15 line-analyzers that need the 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(conf().get("SolverOutput","timeRegExp"))
25 self.progress=progress
26
28 m=self.exp.match(line)
29 if m!=None:
30 try:
31 self.notify(float(m.group(2)))
32 if self.progress and type(self.parent.time)==float:
33 print "\r t = %10g" % self.parent.time,
34 stdout.flush()
35
36 except ValueError:
37 pass
38