Package PyFoam :: Package LogAnalysis :: Module ValueLineAnalyzer
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.LogAnalysis.ValueLineAnalyzer

 1  """Do analysis for a line with values""" 
 2   
 3  import string 
 4   
 5  from FileLineAnalyzer import FileLineAnalyzer 
 6  from  NameFinderLineAnalyzer import NameFinderLineAnalyzer 
 7   
8 -class ValueLineAnalyzer(FileLineAnalyzer):
9 """Parses lines for numeric values 10 11 The line starts with a predefined string""" 12
13 - def __init__(self,name,pre,titles=[]):
14 """ 15 @param name: name of the expression (needed for output) 16 @param pre: the string that starts the line 17 """ 18 FileLineAnalyzer.__init__(self,titles) 19 20 self.name=name 21 self.pre=pre
22
23 - def doAnalysis(self,line):
24 """Analyzes line and writes the data""" 25 tm=self.parent.getTime() 26 if tm=="": 27 return 28 29 m=line.find(self.pre) 30 if m>=0: 31 rest=line[m+len(self.pre):] 32 fdata=() 33 for teil in rest.split(): 34 try: 35 val=float(teil) 36 fdata+=(val,) 37 except ValueError: 38 pass 39 40 self.files.write(self.name,tm,fdata)
41
42 -class ValueNameFinderLineAnalyzer(NameFinderLineAnalyzer):
43 """Finds the names and notifies it's ValueLineAnalyzer""" 44
45 - def __init__(self,trigger,analyze,val,idNr=1,nr=1):
46 """ 47 @param trigger: The regular expression that has to match before data is collected 48 @param nr: The number of lines after the match that data is collected 49 @param analyze: The regular expression that is used for analysis 50 @param idNr: The id of the group that is used for analysis 51 @param val: The ValueLineAnalyzer that needs the names 52 """ 53 54 NameFinderLineAnalyzer.__init__(self,trigger,analyze,idNr=idNr,nr=nr) 55 56 self.val=val
57
58 - def callOnChange(self):
59 self.val.setTitles(self.names)
60