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