Package mrv :: Package automation :: Module report
[hide private]
[frames] | no frames]

Source Code for Module mrv.automation.report

 1  # -*- coding: utf-8 -*- 
 2  """contains report implementations allowing to analyse the callgraph of """ 
 3  __docformat__ = "restructuredtext" 
 4   
 5   
6 -class ReportBase( object ):
7 """Provides main interface for all reports as well as the basic implementation""" 8 9 #{ Overridden Methods
10 - def __init__( self, callgraph ):
11 """intiialize the report with the given callgraph""" 12 self._callgraph = callgraph
13 14 #} END overridden Methods 15 16 #{ Report Methods 17
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" )
21 22 #} END report methods 23 24
25 -class Plan( ReportBase ):
26 """Create a plan-like text describing how the target is being made""" 27
28 - def _analyseCallgraph( self ):
29 """Create a list of ProcessData instances that reflects the call order""" 30 kwargs = {} 31 kwargs[ 'reverse' ] = True 32 return self._callgraph.toCallList( **kwargs )
33 34
35 - def makeReport( self, headline=None ):
36 """ 37 :return: list of strings ( lines ) resembling a plan-like formatting 38 of the call graph 39 :param headline: line to be given as first line """ 40 cl = self._analyseCallgraph( ) 41 42 out = [] 43 if headline: 44 out.append( headline ) 45 46 for i,pedge in enumerate( cl ): 47 sp,ep = pedge 48 i += 1 # plans start at 1 49 # its an edge 50 if ep: 51 line = "%i. %s provides %r through %s to %s" % ( i, sp.process.id(), sp.result(), sp.plug, ep.process.noun ) 52 else: 53 # its root 54 line = "%i. %s %s %r when asked for %s" % ( i, sp.process.id(), sp.process.verb, sp.result(), sp.plug ) 55 out.append( line ) 56 # END for each process data edge 57 return out
58