2
"""contains report implementations allowing to analyse the callgraph of """
3
__docformat__ = "restructuredtext"
6
class ReportBase( object ):
7
"""Provides main interface for all reports as well as the basic implementation"""
10
def __init__( self, callgraph ):
11
"""intiialize the report with the given callgraph"""
12
self._callgraph = callgraph
14
#} END overridden Methods
18
def makeReport( self ):
19
""":return: report as result of a prior Callgraph analysis"""
20
raise NotImplementedError( "This method needs to be implemented by subclasses" )
25
class Plan( ReportBase ):
26
"""Create a plan-like text describing how the target is being made"""
28
def _analyseCallgraph( self ):
29
"""Create a list of ProcessData instances that reflects the call order"""
31
kwargs[ 'reverse' ] = True
32
return self._callgraph.toCallList( **kwargs )
35
def makeReport( self, headline=None ):
37
:return: list of strings ( lines ) resembling a plan-like formatting
39
:param headline: line to be given as first line """
40
cl = self._analyseCallgraph( )
44
out.append( headline )
46
for i,pedge in enumerate( cl ):
48
i += 1 # plans start at 1
51
line = "%i. %s provides %r through %s to %s" % ( i, sp.process.id(), sp.result(), sp.plug, ep.process.noun )
54
line = "%i. %s %s %r when asked for %s" % ( i, sp.process.id(), sp.process.verb, sp.result(), sp.plug )
56
# END for each process data edge