1 """Line analyzer with output and the capability to store lines"""
2
3 from LogLineAnalyzer import LogLineAnalyzer
4 from PyFoam.Basics.OutFileCollection import OutFileCollection
5 from PyFoam.Basics.TimeLineCollection import TimeLineCollection
6
8 """Base class for analyzers that write data to files and store time-lines
9
10 Combines the capabilities of TimeLineLineAnalyzer and FileLineAnalyzer"""
11
12 - def __init__(self,doTimelines=False,doFiles=False,titles=[]):
13 """
14 @param titles: The titles of the data elements
15 """
16 LogLineAnalyzer.__init__(self)
17
18 self.doTimelines=doTimelines
19 self.doFiles=doFiles
20
21 self.files=None
22 self.titles=titles
23
24 self.setTitles(titles)
25 if self.doTimelines:
26 self.lines=TimeLineCollection()
27 else:
28 self.lines=None
29
31 """
32 Sets the titles anew
33 @param titles: the new titles
34 """
35 if self.doFiles:
36 self.titles=titles
37 if self.files!=None:
38 self.files.setTitles(titles)
39
41 """Creates the OutFileCollection-object"""
42 if self.doFiles:
43 self.files=OutFileCollection(oDir,titles=self.titles)
44 else:
45 self.files=None
46
48 """Sets the current time in the timelines"""
49 if self.doTimelines:
50 self.lines.setTime(self.getTime())
51
53 """@param name: Name of the timeline to return
54 @return: the timeline as two list: the times and the values"""
55 if self.doTimelines:
56 return self.lines.getTimes(),self.lines.getValues(name)
57 else:
58 return [],[]
59
61 """General analysis method. Derived classes should instead override callbacks"""
62
63 m=self.exp.match(line)
64 if m!=None:
65 self.startAnalysis(m)
66
67 if self.doTimelines:
68 self.addToTimelines(m)
69 if self.doFiles:
70 self.addToFiles(m)
71
72 self.endAnalysis(m)
73
75 """Method at the start of a successfull match"""
76 pass
77
79 """Method at the end of a successfull match"""
80 pass
81
83 """Method that adds matched data to timelines
84
85 @param match: data matched by a regular expression"""
86
87 pass
88
90 """Method that adds matched data to files
91
92 @param match: data matched by a regular expression"""
93
94 pass
95