Package PyFoam :: Package Execution :: Module AnalyzedCommon
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Execution.AnalyzedCommon

 1  """Common stuff for classes that use analyzers""" 
 2   
 3  from os import path,mkdir 
 4   
5 -class AnalyzedCommon(object):
6 """This class collects information and methods that are needed for 7 handling analyzers""" 8
9 - def __init__(self,filename,analyzer):
10 """@param filename: name of the file that is being analyzed 11 @param analyzer: the analyzer itself""" 12 13 self.analyzer=analyzer 14 15 if 'dir' in dir(self): 16 self.logDir=path.join(self.dir,filename+".analyzed") 17 else: 18 self.logDir=filename+".analyzed" 19 20 if not path.exists(self.logDir): 21 mkdir(self.logDir) 22 23 self.reset()
24
25 - def tearDown(self):
26 self.analyzer.tearDown()
27
28 - def listAnalyzers(self):
29 """@returns: A list with the names of the analyzers""" 30 return self.analyzer.listAnalyzers()
31
32 - def getAnalyzer(self,name):
33 """@param name: name of the LineAnalyzer to get""" 34 return self.analyzer.getAnalyzer(name)
35
36 - def addAnalyzer(self,name,analyzer):
37 """@param name: name of the LineAnalyzer to add 38 @param analyzer: the analyzer to add""" 39 return self.analyzer.addAnalyzer(name,analyzer)
40
41 - def lineHandle(self,line):
42 """Not to be called: calls the analyzer for the current line""" 43 self.analyzer.analyzeLine(line)
44
45 - def reset(self):
46 """reset the analyzer""" 47 self.analyzer.setDirectory(self.logDir)
48
49 - def getDirname(self):
50 """Get the name of the directory where the data is written to""" 51 return self.logDir
52
53 - def getTime(self):
54 """Get the execution time""" 55 return self.analyzer.getTime()
56