CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
cfg-viewer.visitor Class Reference

Public Member Functions

def __init__ (self, df, cfg)
 
def enter (self, value)
 
def leave (self, value)
 

Public Attributes

 config
 

Private Member Functions

def _doModules (self, modObj, dataFile, seq, seqs, currentName, innerSeq)
 
def _finalExit (self)
 
def _getType (self, val)
 

Private Attributes

 _currentName
 
 _df
 
 _done
 
 _innerSeq
 
 _modulesToPaths
 
 _oldNames
 
 _pathLength
 
 _reg
 
 _seq
 
 _seqs
 
 _typeNumbers
 
 _underPath
 

Detailed Description

Definition at line 522 of file cfg-viewer.py.

Constructor & Destructor Documentation

def cfg-viewer.visitor.__init__ (   self,
  df,
  cfg 
)

Definition at line 523 of file cfg-viewer.py.

523  def __init__(self, df, cfg):
524  self._df = df
525  self._underPath = [] # direct children of paths
526  #(includes children of modules)
527  self._modulesToPaths={} # map from modules to index of path -
528  self._seq = 0
529  self._pathLength=0
530  self._currentName =""
531  self._oldNames =[]
532  self._done =[]
533  self._seqs={}
534  self._typeNumbers = {}
535  self._innerSeq = False
536  self._reg= re.compile("<|>|'")
537  self.config = cfg
538 
def __init__(self, df, cfg)
Definition: cfg-viewer.py:523

Member Function Documentation

def cfg-viewer.visitor._doModules (   self,
  modObj,
  dataFile,
  seq,
  seqs,
  currentName,
  innerSeq 
)
private

Definition at line 552 of file cfg-viewer.py.

References cfg-viewer.visitor._getType(), cfg-viewer.visitor._modulesToPaths, cfg-viewer.visitor._pathLength, mps_setup.append, cfg-viewer.doTypes(), cfg-viewer.getParameters(), cfg-viewer.getParamSeqDict(), reco.if(), and cfg-viewer.JSONFormat().

Referenced by cfg-viewer.visitor.enter().

552  def _doModules(self,modObj, dataFile, seq, seqs, currentName, innerSeq):
553  #name = modObj.label_()
554  name = self.config.label(modObj)
555  # If this is not an inner sequence then we add so it can go to paths
556  if(seq==0):
557  self._underPath.append(name)
558  else:
559  seqs[currentName].append([name])
560  # If we've seen this name before, no need to compute values again.
561  # we need to put this mod/seq name under the path name in the dict
562  if(name not in self._modulesToPaths.keys()):
563  self._modulesToPaths[name] =[self._pathLength]
564  filename = modObj._filename.split("/")[-1]
565  generic,specific = self._getType(modObj)
566  doTypes(specific,generic)
567  d = getParamSeqDict(getParameters(modObj.parameters_()),
568  filename, specific, modObj.type_())
569  theS='"%s":%s'
570  if(len(self._modulesToPaths.keys()) > 1): theS=","+theS
571  dataFile.write(theS%(name, JSONFormat(d)))
572  else:
573  #oldMods.append(name)
574  self._modulesToPaths[name].append(self._pathLength)
575 
def getParameters(parameters)
Definition: cfg-viewer.py:438
def _getType(self, val)
Definition: cfg-viewer.py:546
def _doModules(self, modObj, dataFile, seq, seqs, currentName, innerSeq)
Definition: cfg-viewer.py:552
def getParamSeqDict(params, fil, typ, oType)
Definition: cfg-viewer.py:514
def JSONFormat(d)
Definition: cfg-viewer.py:1264
def doTypes(spec, generic)
Definition: cfg-viewer.py:1261
if(dp >Float(M_PI)) dp-
def cfg-viewer.visitor._finalExit (   self)
private

Definition at line 539 of file cfg-viewer.py.

References cfg-viewer.visitor._pathLength, and cfg-viewer.visitor._underPath.

539  def _finalExit(self):
540  self._pathLength+=1
541  temp = self._underPath
542  self._underPath =[]
543  return temp
544 
def _finalExit(self)
Definition: cfg-viewer.py:539
def cfg-viewer.visitor._getType (   self,
  val 
)
private
def cfg-viewer.visitor.enter (   self,
  value 
)

Definition at line 576 of file cfg-viewer.py.

References cfg-viewer.visitor._currentName, cfg-viewer.visitor._df, cfg-viewer.visitor._doModules(), cfg-viewer.visitor._done, cfg-viewer.visitor._getType(), cfg-viewer.visitor._innerSeq, SequenceTypes._ModuleSequenceType._seq, cfg-viewer.visitor._seq, cfg-viewer.visitor._seqs, mps_setup.append, cfg-viewer.doTypes(), cfg-viewer.getParamSeqDict(), reco.if(), and cfg-viewer.JSONFormat().

576  def enter(self, value):
577  if(isinstance(value,cms._Module)):
578  self._doModules(value, self._df, self._seq,
579  self._seqs, self._currentName, self._innerSeq)
580  elif(isinstance(value,cms._Sequenceable)):
581  generic,specific = self._getType(value)
582  doTypes(specific, generic)
583  if(isinstance(value, cms._ModuleSequenceType)):
584  if(len(self._currentName) >0):
585  self._oldNames.insert(0, self._currentName)
586  name = self.config.label(value)
587  #name = value.label_()
588  if(self._seq >0):
589  # this is an inner sequence
590  self._innerSeq = True;
591  self._seqs[self._currentName].append([name])
592  else:
593  self._underPath.append(name)
594  self._seqs[name] = []
595  self._currentName = name
596  self._seq +=1
597  else:
598  # just sequenceable..
599  name = value.__str__()
600  if(self._currentName):
601  self._seqs[self._currentName].append([name, specific])
602  else:
603  self._underPath.append(value.__str__())
604  if(name not in self._done):
605  d = getParamSeqDict([], "", specific, "")
606  self._df.write(',"%s":%s'%(name,JSONFormat(d)))
607  self._done.append(name)
608 
def enter(self, value)
Definition: cfg-viewer.py:576
def _getType(self, val)
Definition: cfg-viewer.py:546
def _doModules(self, modObj, dataFile, seq, seqs, currentName, innerSeq)
Definition: cfg-viewer.py:552
def getParamSeqDict(params, fil, typ, oType)
Definition: cfg-viewer.py:514
def JSONFormat(d)
Definition: cfg-viewer.py:1264
def doTypes(spec, generic)
Definition: cfg-viewer.py:1261
if(dp >Float(M_PI)) dp-
def cfg-viewer.visitor.leave (   self,
  value 
)

Definition at line 609 of file cfg-viewer.py.

References cfg-viewer.visitor._currentName, cfg-viewer.visitor._done, cfg-viewer.visitor._getType(), cfg-viewer.visitor._innerSeq, cfg-viewer.visitor._oldNames, SequenceTypes._ModuleSequenceType._seq, cfg-viewer.visitor._seq, cfg-viewer.getParamSeqDict(), reco.if(), and cfg-viewer.JSONFormat().

609  def leave(self, value):
610  if(isinstance(value,cms._Module)):
611  return
612  elif(isinstance(value,cms._Sequenceable)):
613  # now need to determine difference between
614  #ones which have lists and ones which dont
615  if(isinstance(value, cms._ModuleSequenceType)):
616  #name = value.label()
617  name = self.config.label(value)
618  if(name in self._oldNames):self._oldNames.remove(name)
619  if(self._currentName == name):
620  if(self._oldNames):
621  self._currentName = self._oldNames.pop(0)
622  else:
623  self._currentName=""
624  if(name not in self._done):
625  generic,specific = self._getType(value)
626  d = getParamSeqDict(self._seqs.pop(name), "", specific, "")
627  self._df.write(',"%s":%s'%(name,JSONFormat(d)))
628  self._done.append(name)
629  self._seq -=1
630  if(self._seq==0): self._innerSeq = False;
631 
def _getType(self, val)
Definition: cfg-viewer.py:546
def leave(self, value)
Definition: cfg-viewer.py:609
def getParamSeqDict(params, fil, typ, oType)
Definition: cfg-viewer.py:514
def JSONFormat(d)
Definition: cfg-viewer.py:1264
if(dp >Float(M_PI)) dp-

Member Data Documentation

cfg-viewer.visitor._currentName
private

Definition at line 530 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter(), and cfg-viewer.visitor.leave().

cfg-viewer.visitor._df
private

Definition at line 524 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter().

cfg-viewer.visitor._done
private

Definition at line 532 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter(), and cfg-viewer.visitor.leave().

cfg-viewer.visitor._innerSeq
private

Definition at line 535 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter(), and cfg-viewer.visitor.leave().

cfg-viewer.visitor._modulesToPaths
private

Definition at line 527 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor._doModules().

cfg-viewer.visitor._oldNames
private

Definition at line 531 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.leave().

cfg-viewer.visitor._pathLength
private

Definition at line 529 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor._doModules(), and cfg-viewer.visitor._finalExit().

cfg-viewer.visitor._reg
private

Definition at line 536 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor._getType().

cfg-viewer.visitor._seq
private

Definition at line 528 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter(), and cfg-viewer.visitor.leave().

cfg-viewer.visitor._seqs
private

Definition at line 533 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor.enter().

cfg-viewer.visitor._typeNumbers
private

Definition at line 534 of file cfg-viewer.py.

cfg-viewer.visitor._underPath
private

Definition at line 525 of file cfg-viewer.py.

Referenced by cfg-viewer.visitor._finalExit().

cfg-viewer.visitor.config

Definition at line 537 of file cfg-viewer.py.