CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
DOTExport.DotProducer Class Reference
Inheritance diagram for DOTExport.DotProducer:

Public Member Functions

def __call__
 
def __init__
 
def connectPaths
 
def connectTags
 
def getTopLevel
 
def makePath
 
def nodeLabel
 
def nodeURL
 
def produceLegend
 
def produceNodes
 
def producePaths
 
def produceServices
 
def produceSource
 
def recurseChildren
 
def seqRecurseChildren
 

Public Attributes

 data
 
 endstarts
 
 nodes
 
 options
 
 pathends
 
 pathstarts
 
 shapes
 
 toplevel
 

Detailed Description

Definition at line 18 of file DOTExport.py.

Constructor & Destructor Documentation

def DOTExport.DotProducer.__init__ (   self,
  data,
  options,
  shapes 
)

Definition at line 19 of file DOTExport.py.

19 
20  def __init__(self,data,options,shapes):
21  self.data = data
22  self.options = options
23  self.shapes = shapes
24  self.nodes={}
25  #lists of starts, ends of paths for path-endpath and source-path connections
26  self.pathstarts=[]
27  self.pathends=[]
28  self.endstarts=[]
29  self.toplevel = self.getTopLevel()

Member Function Documentation

def DOTExport.DotProducer.__call__ (   self)

Definition at line 240 of file DOTExport.py.

References DOTExport.DotProducer.connectPaths(), DOTExport.DotProducer.connectTags(), join(), DOTExport.DotProducer.options, DOTExport.DotProducer.produceLegend(), DOTExport.DotProducer.produceNodes(), DOTExport.DotProducer.producePaths(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.produceSource().

241  def __call__(self):
242  blocks=[]
243  if self.options['legend']:
244  blocks += [self.produceLegend()]
245  blocks += [self.producePaths()]
246  if self.options['seqconnect']:
247  blocks += [self.connectPaths()]
248  if self.options['tagconnect']:
249  blocks += [self.connectTags()]
250  if self.options['source']:
251  blocks += [self.produceSource()]
252  if self.options['es'] or self.options['services']:
253  blocks += [self.produceServices()]
254  blocks += [self.produceNodes()]
255  if self.data.process():
256  return 'digraph configbrowse {\nsubgraph clusterProcess {\nlabel="%s\\n%s"\nfontsize=%s\nfontname="%s"\n%s\n}\n}\n' % (self.data.process().name_(),self.data._filename,self.options['font_size'],self.options['font_name'],'\n'.join(blocks))
257  else:
258  return 'digraph configbrowse {\nsubgraph clusterCFF {\nlabel="%s"\nfontsize=%s\nfontname="%s"\n%s\n}\n}\n' % (self.data._filename,self.options['font_size'],self.options['font_name'],'\n'.join(blocks))
259 
260 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DOTExport.DotProducer.connectPaths (   self)

Definition at line 159 of file DOTExport.py.

References DOTExport.DotProducer.endstarts, and DOTExport.DotProducer.pathends.

Referenced by DOTExport.DotProducer.__call__().

160  def connectPaths(self):
161  result=''
162  for p in self.pathends:
163  for p2 in self.endstarts:
164  result+="%s->%s\n" % (p,p2)
165  return result
def DOTExport.DotProducer.connectTags (   self)

Definition at line 166 of file DOTExport.py.

References DOTExport.DotProducer.nodes, and DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.__call__().

167  def connectTags(self):
168  #if we are connecting by tag, add labelled tag joining lines
169  #this doesn't have to be exclusive with sequence connection, by stylistically probably should be
170  result=''
171  allobjects = [self.nodes[n]['obj'] for n in self.nodes if self.nodes[n]['inpath']]
172  self.data.readConnections(allobjects)
173  connections = self.data.connections()
174  for objects,names in connections.items():
175  if self.options['taglabel']:
176  result += '%s->%s[label="%s",color="%s",fontcolor="%s",fontsize=%s,fontname="%s"]\n' % (objects[0],objects[1],names[1],self.options['color_inputtag'],self.options['color_inputtag'],self.options['font_size'],self.options['font_name'])
177  else:
178  result += '%s->%s[color="%s"]\n' % (objects[0],objects[1],self.options['color_inputtag'])
179  return result
180 
def DOTExport.DotProducer.getTopLevel (   self)

Definition at line 30 of file DOTExport.py.

References DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, and DOTExport.DotProducer.options.

30 
31  def getTopLevel(self):
32 
33  #build a dictionary of available top-level objects
34  all_toplevel={}
35  if self.data.process():
36  for tlo in self.data.children(self.data.topLevelObjects()[0]):
37  children = self.data.children(tlo)
38  if children:
39  all_toplevel[tlo._label]=children
40  else:
41  #case if we have only an anonymous (non-process) file
42  #pick up (modules, sequences, paths)
43  for tlo in self.data.topLevelObjects():
44  if self.data.type(tlo)=='Sequence':
45  if 'sequences' in all_toplevel:
46  all_toplevel['sequences']+=[tlo]
47  else:
48  all_toplevel['sequences']=[tlo]
49  if self.data.type(tlo)=='Path':
50  if 'paths' in all_toplevel:
51  all_toplevel['paths']+=[tlo]
52  else:
53  all_toplevel['paths']=[tlo]
54  if self.data.type(tlo) in ('EDAnalyzer','EDFilter','EDProducer','OutputModule'):
55  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':True}
56  if self.options['services'] and self.data.type(tlo)=='Service':
57  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':False}
58  if self.options['es'] and self.data.type(tlo) in ('ESSource','ESProducer'):
59  self.nodes[self.data.label(tlo)]={'obj':tlo,'n_label':self.nodeLabel(tlo),'n_shape':self.shapes.get(self.data.type(tlo),'plaintext'),'inpath':False}
60  return all_toplevel
def DOTExport.DotProducer.makePath (   self,
  path,
  endpath = False 
)

Definition at line 103 of file DOTExport.py.

References join(), DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DOTExport.DotProducer.options, DOTExport.DotProducer.recurseChildren(), and DOTExport.DotProducer.seqRecurseChildren().

Referenced by DOTExport.DotProducer.producePaths().

104  def makePath(self,path,endpath=False):
105  children = self.recurseChildren(path)
106  pathlabel = self.data.label(path)
107  if self.options['file']:
108  pathlabel += '\\n%s:%s'%(self.data.pypackage(path),self.data.lineNumber(path))
109  if endpath:
110  pathresult = 'subgraph cluster%s {\nlabel="%s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(path),pathlabel,self.options['color_endpath'],self.options['color_endpath'],self.options['font_name'],self.options['font_size'])
111  else:
112  pathresult = 'subgraph cluster%s {\nlabel="%s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(path),pathlabel,self.options['color_path'],self.options['color_path'],self.options['font_name'],self.options['font_size'])
113  if self.options['seqconnect']:
114  if endpath:
115  self.endstarts.append('endstart_%s'%self.data.label(path))
116  self.nodes['endstart_%s'%self.data.label(path)]={'obj':path,'n_label':'Start %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
117  else:
118  self.pathstarts.append('start_%s'%self.data.label(path))
119  self.pathends.append('end_%s'%self.data.label(path))
120  self.nodes['start_%s'%self.data.label(path)]={'obj':path,'n_label':'Start %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
121  self.nodes['end_%s'%self.data.label(path)]={'obj':path,'n_label':'End %s'%self.data.label(path),'n_color':'grey','n_shape':'plaintext','inpath':False}
122  labels=[]
123  for c in children:
124  #this is also done in seqRecurseChildren, so will be duplicated
125  #unncessary, but relatively cheap and saves more cff/cfg conditionals
126  self.nodes[self.data.label(c)]={'obj':c,'n_label':self.nodeLabel(c),'n_shape':self.shapes.get(self.data.type(c),'plaintext'),'inpath':True}
127  labels.append(self.data.label(c))
128  if self.options['seqconnect']:
129  pathresult += '->'.join(labels)+'\n'
130  else:
131  if not self.options['seq']:
132  pathresult += '\n'.join(labels)+'\n'
133  if self.options['seq']:
134  if self.data.children(path):
135  for path_child in self.data.children(path):
136  pathresult += self.seqRecurseChildren(path_child)
137  pathresult += '}\n'
138  if len(labels)>0 and self.options['seqconnect']:
139  if endpath:
140  pathresult += 'endstart_%s->%s\n' % (self.data.label(path),labels[0])
141  else:
142  pathresult += 'start_%s->%s\n%s->end_%s\n' % (self.data.label(path),labels[0],labels[-1],self.data.label(path))
143 
144  return pathresult
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DOTExport.DotProducer.nodeLabel (   self,
  obj 
)

Definition at line 87 of file DOTExport.py.

References DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.getTopLevel(), DOTExport.DotProducer.makePath(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.seqRecurseChildren().

87 
88  def nodeLabel(self,obj):
89  result = self.data.label(obj)
90  if self.options['class']:
91  result += '\\n%s'%self.data.classname(obj)
92  if self.options['file']:
93  result += '\\n%s:%s'%(self.data.pypackage(obj),self.data.lineNumber(obj))
94  return result
95 
#generate an appropriate URL by replacing placeholders in baseurl
def DOTExport.DotProducer.nodeURL (   self,
  obj 
)

Definition at line 96 of file DOTExport.py.

References DOTExport.DotProducer.options, and python.rootplot.root2matplotlib.replace().

Referenced by DOTExport.DotProducer.produceNodes().

96 
97  def nodeURL(self,obj):
98  classname = self.data.classname(obj)
99  pypath = self.data.pypath(obj)
100  pyline = self.data.lineNumber(obj)
101  url = self.options['urlbase'].replace('$classname',classname).replace('$pypath',pypath).replace('$pyline',pyline)
102  return url
def DOTExport.DotProducer.produceLegend (   self)
Return a legend subgraph using current shape and colour preferences.

Definition at line 234 of file DOTExport.py.

References DOTExport.DotProducer.options, DOTExport.DotProducer.shapes, and EcalLaserAnalyzer2.shapes.

Referenced by DOTExport.DotProducer.__call__().

235  def produceLegend(self):
236  """
237  Return a legend subgraph using current shape and colour preferences.
238  """
239  return 'subgraph clusterLegend {\nlabel="legend"\ncolor=red\nSource->Producer->Filter->Analyzer\nService->ESSource[style=invis]\nESSource->ESProducer[style=invis]\nProducer->Filter[color="%s",label="InputTag",fontcolor="%s"]\nProducer[shape=%s]\nFilter[shape=%s]\nAnalyzer[shape=%s]\nESSource[shape=%s]\nESProducer[shape=%s]\nSource[shape=%s]\nService[shape=%s]\nsubgraph clusterLegendSequence {\nlabel="Sequence"\ncolor="%s"\nfontcolor="%s"\nProducer\nFilter\n}\n}\n' % (self.options['color_inputtag'],self.options['color_inputtag'],self.shapes['EDProducer'],self.shapes['EDFilter'],self.shapes['EDAnalyzer'],self.shapes['ESSource'],self.shapes['ESProducer'],self.shapes['Source'],self.shapes['Service'],self.options['color_sequence'],self.options['color_sequence'])
def DOTExport.DotProducer.produceNodes (   self)

Definition at line 224 of file DOTExport.py.

References join(), DOTExport.DotProducer.nodes, DOTExport.DotProducer.nodeURL(), and DOTExport.DotProducer.options.

Referenced by DOTExport.DotProducer.__call__().

225  def produceNodes(self):
226  result=''
227  for n in self.nodes:
228  self.nodes[n]['n_fontname']=self.options['font_name']
229  self.nodes[n]['n_fontsize']=self.options['font_size']
230  if self.options['url']:
231  self.nodes[n]['n_URL']=self.nodeURL(self.nodes[n]['obj'])
232  result += "%s[%s]\n" % (n,','.join(['%s="%s"' % (k[2:],v) for k,v in self.nodes[n].items() if k[0:2]=='n_']))
233  return result
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DOTExport.DotProducer.producePaths (   self)

Definition at line 145 of file DOTExport.py.

References DOTExport.DotProducer.makePath(), Json::Path.makePath(), DOTExport.DotProducer.options, DOTExport.DotProducer.seqRecurseChildren(), and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

146  def producePaths(self):
147  result=''
148  if 'paths' in self.toplevel:
149  for path in self.toplevel['paths']:
150  result += self.makePath(path)
151  if self.options['endpath']:
152  if 'endpaths' in self.toplevel:
153  for path in self.toplevel['endpaths']:
154  result += self.makePath(path,True)
155  if 'sequences' in self.toplevel:
156  for seq in self.toplevel['sequences']:
157  result += self.seqRecurseChildren(seq)
158  return result
def DOTExport.DotProducer.produceServices (   self)

Definition at line 194 of file DOTExport.py.

References bookConverter.max, DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DOTExport.DotProducer.options, DOTExport.DotProducer.recurseChildren(), DOTExport.DotProducer.shapes, EcalLaserAnalyzer2.shapes, and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

195  def produceServices(self):
196  # add service, eventsetup nodes
197  # this will usually result in thousands and isn't that interesting
198  servicenodes=[]
199  result=''
200  if self.options['es']:
201  if 'essources' in self.toplevel:
202  for e in self.toplevel['essources']:
203  servicenodes.append(self.data.label(e))
204  self.nodes[self.data.label(e)]={'obj':e,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['ESSource'],'inpath':False}
205  if 'esproducers' in self.toplevel:
206  for e in self.toplevel['esproducers']:
207  servicenodes.append(self.data.label(e))
208  self.nodes[self.data.label(e)]={'obj':e,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['ESProducer'],'inpath':False}
209  if self.options['services']:
210  if 'services' in self.toplevel:
211  for s in self.toplevel['services']:
212  self.servicenodes.append(self.data.label(s))
213  self.nodes[self.data.label(s)]={'obj':s,'n_label':self.nodeLabel(e), 'n_shape':self.shapes['Service'],'inpath':False}
214  #find the maximum path and endpath lengths for servicenode layout
215  maxpath=max([len(recurseChildren(path) for path in self.toplevel.get('paths',(0,)))])
216  maxendpath=max([len(recurseChildren(path) for path in self.toplevel.get('endpaths',(0,)))])
217 
218  #add invisible links between service nodes where necessary to ensure they only fill to the same height as the longest path+endpath
219  #this constraint should only apply for link view
220  for i,s in enumerate(servicenodes[:-1]):
221  if not i%(maxpath+maxendpath)==(maxpath+maxendpath)-1:
222  result+='%s->%s[style=invis]\n' % (s,servicenodes[i+1])
223  return result
def DOTExport.DotProducer.produceSource (   self)

Definition at line 181 of file DOTExport.py.

References DOTExport.DotProducer.nodes, DOTExport.DotProducer.options, DOTExport.DotProducer.pathstarts, DOTExport.DotProducer.shapes, EcalLaserAnalyzer2.shapes, and DOTExport.DotProducer.toplevel.

Referenced by DOTExport.DotProducer.__call__().

182  def produceSource(self):
183  #add the source
184  #if we are connecting sequences, connect it to all the path starts
185  #if we are connecting sequences and have a schedule, connect it to path #0
186  result=''
187  if 'source' in self.toplevel:
188  for s in self.toplevel['source']:
189  self.nodes['source']={'obj':s,'n_label':self.data.classname(s),'n_shape':self.shapes['Source']}
190  if self.options['seqconnect']:
191  for p in self.pathstarts:
192  result += 'source->%s\n' % (p)
193  return result
def DOTExport.DotProducer.recurseChildren (   self,
  obj 
)

Definition at line 76 of file DOTExport.py.

References DOTExport.DotProducer.recurseChildren().

Referenced by DOTExport.DotProducer.makePath(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.recurseChildren().

76 
77  def recurseChildren(self,obj):
78  result=[]
79  children=self.data.children(obj)
80  if children:
81  for c in children:
82  result += self.recurseChildren(c)
83  else:
84  result.append(obj)
85  return result
def DOTExport.DotProducer.seqRecurseChildren (   self,
  obj 
)

Definition at line 61 of file DOTExport.py.

References DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodes, DOTExport.DotProducer.options, and DOTExport.DotProducer.seqRecurseChildren().

Referenced by DOTExport.DotProducer.makePath(), DOTExport.DotProducer.producePaths(), and DOTExport.DotProducer.seqRecurseChildren().

61 
62  def seqRecurseChildren(self,obj):
63  children = self.data.children(obj)
64  if children:
65  seqlabel = self.data.label(obj)
66  if self.options['file']:
67  seqlabel += '\\n%s:%s' % (self.data.pypackage(obj),self.data.lineNumber(obj))
68  result='subgraph clusterSeq%s {\nlabel="Sequence %s"\ncolor="%s"\nfontcolor="%s"\nfontname="%s"\nfontsize=%s\n' % (self.data.label(obj),seqlabel,self.options['color_sequence'],self.options['color_sequence'],self.options['font_name'],self.options['font_size'])
69  for c in children:
70  result += self.seqRecurseChildren(c)
71  result+='}\n'
72  return result
73  else:
74  self.nodes[self.data.label(obj)]={'obj':obj,'n_label':self.nodeLabel(obj),'n_shape':self.shapes.get(self.data.type(obj),'plaintext'),'inpath':True}
75  return '%s\n'%self.data.label(obj)

Member Data Documentation

DOTExport.DotProducer.data

Definition at line 20 of file DOTExport.py.

Referenced by cuy.FindIssue.__init__(), confdb.HLTProcess.customize(), confdb.HLTProcess.dump(), confdb.HLTProcess.getRawConfigurationFromDB(), and confdb.HLTProcess.specificCustomize().

DOTExport.DotProducer.endstarts

Definition at line 27 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

DOTExport.DotProducer.nodes

Definition at line 23 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectTags(), DOTExport.DotProducer.getTopLevel(), DOTExport.DotProducer.makePath(), DOTExport.DotProducer.produceNodes(), DOTExport.DotProducer.produceServices(), DOTExport.DotProducer.produceSource(), and DOTExport.DotProducer.seqRecurseChildren().

DOTExport.DotProducer.options

Definition at line 21 of file DOTExport.py.

Referenced by DOTExport.DotProducer.__call__(), betterConfigParser.BetterConfigParser.__updateDict(), betterConfigParser.BetterConfigParser.checkInput(), DOTExport.DotProducer.connectTags(), DOTExport.DotExport.export(), DOTExport.DotProducer.getTopLevel(), DOTExport.DotProducer.makePath(), DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodeURL(), DOTExport.DotProducer.produceLegend(), DOTExport.DotProducer.produceNodes(), DOTExport.DotProducer.producePaths(), DOTExport.DotProducer.produceServices(), DOTExport.DotProducer.produceSource(), DOTExport.DotProducer.seqRecurseChildren(), FileExportPlugin.FileExportPlugin.setOption(), and DOTExport.DotExport.write_output().

DOTExport.DotProducer.pathends

Definition at line 26 of file DOTExport.py.

Referenced by DOTExport.DotProducer.connectPaths().

DOTExport.DotProducer.pathstarts

Definition at line 25 of file DOTExport.py.

Referenced by DOTExport.DotProducer.produceSource().

DOTExport.DotProducer.shapes

Definition at line 22 of file DOTExport.py.

Referenced by DOTExport.DotExport.export(), DOTExport.DotProducer.produceLegend(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.produceSource().

DOTExport.DotProducer.toplevel

Definition at line 28 of file DOTExport.py.

Referenced by DOTExport.DotProducer.producePaths(), DOTExport.DotProducer.produceServices(), and DOTExport.DotProducer.produceSource().