1
2 """Common stuff for classes that use analyzers"""
3
4 from os import path,mkdir
5
7 """This class collects information and methods that are needed for
8 handling analyzers"""
9
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
28
30 """@returns: A list with the names of the analyzers"""
31 return self.analyzer.listAnalyzers()
32
34 """@param name: name of the LineAnalyzer to get"""
35 return self.analyzer.getAnalyzer(name)
36
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
44 """Not to be called: calls the analyzer for the current line"""
45 self.analyzer.analyzeLine(line)
46
48 """reset the analyzer"""
49 self.analyzer.setDirectory(self.logDir)
50
52 """Get the name of the directory where the data is written to"""
53 return self.logDir
54
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