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

Source Code for Module PyFoam.Execution.AnalyzedCommon

 1  #  ICE Revision: $Id: AnalyzedCommon.py 8317 2007-12-21 14:45:09Z bgschaid $  
 2  """Common stuff for classes that use analyzers""" 
 3   
 4  from os import path,mkdir 
 5   
6 -class AnalyzedCommon(object):
7 """This class collects information and methods that are needed for 8 handling analyzers""" 9
10 - def __init__(self,filename,analyzer):
11 """@param filename: name of the file that is being analyzed 12 @param analyzer: the analyzer itself""" 13 14 self.analyzer=analyzer 15 16 if 'dir' in dir(self): 17 self.logDir=path.join(self.dir,filename+".analyzed") 18 else: 19 self.logDir=filename+".analyzed" 20 21 if not path.exists(self.logDir): 22 mkdir(self.logDir) 23 24 self.reset()
25
26 - def tearDown(self):
27 self.analyzer.tearDown()
28
29 - def listAnalyzers(self):
30 """@returns: A list with the names of the analyzers""" 31 return self.analyzer.listAnalyzers()
32
33 - def getAnalyzer(self,name):
34 """@param name: name of the LineAnalyzer to get""" 35 return self.analyzer.getAnalyzer(name)
36
37 - def addAnalyzer(self,name,analyzer):
38 """@param name: name of the LineAnalyzer to add 39 @param analyzer: the analyzer to add""" 40 analyzer.setDirectory(self.logDir) 41 return self.analyzer.addAnalyzer(name,analyzer)
42
43 - def lineHandle(self,line):
44 """Not to be called: calls the analyzer for the current line""" 45 self.analyzer.analyzeLine(line)
46
47 - def reset(self):
48 """reset the analyzer""" 49 self.analyzer.setDirectory(self.logDir)
50
51 - def getDirname(self):
52 """Get the name of the directory where the data is written to""" 53 return self.logDir
54
55 - def getTime(self):
56 """Get the execution time""" 57 return self.analyzer.getTime()
58
59 - def addTrigger(self,time,func,once=True,until=None):
60 """Adds a timed trigger to the Analyzer 61 @param time: the time at which the function should be triggered 62 @param func: the trigger function 63 @param once: Should this function be called once or at every time-step 64 @param until: The time until which the trigger should be called""" 65 66 self.analyzer.addTrigger(time,func,once=once,until=until)
67