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 | Private Member Functions | Private Attributes
cfg-viewer.visitor Class Reference

Public Member Functions

def __init__
 
def enter
 
def leave
 

Public Attributes

 config
 

Private Member Functions

def _doModules
 
def _finalExit
 
def _getType
 

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.

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

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, python.multivaluedict.append(), cfg-viewer.doTypes(), cfg-viewer.getParameters(), cfg-viewer.getParamSeqDict(), citk.if(), and cfg-viewer.JSONFormat().

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

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

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

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

References cfg-viewer.unscheduled._reg, MELaserPrim._reg, cfg-viewer.visitor._reg, and split.

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

547  def _getType(self,val):
548  return re.sub(self._reg, "", str(type(val))).split(".")[-2:]
double split
Definition: MVATrainer.cc:139
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, python.multivaluedict.append(), cfg-viewer.doTypes(), cfg-viewer.getParamSeqDict(), citk.if(), and cfg-viewer.JSONFormat().

577  def enter(self, value):
578  if(isinstance(value,cms._Module)):
579  self._doModules(value, self._df, self._seq,
580  self._seqs, self._currentName, self._innerSeq)
581  elif(isinstance(value,cms._Sequenceable)):
582  generic,specific = self._getType(value)
583  doTypes(specific, generic)
584  if(isinstance(value, cms._ModuleSequenceType)):
585  if(len(self._currentName) >0):
586  self._oldNames.insert(0, self._currentName)
587  name = self.config.label(value)
588  #name = value.label_()
589  if(self._seq >0):
590  # this is an inner sequence
591  self._innerSeq = True;
592  self._seqs[self._currentName].append([name])
593  else:
594  self._underPath.append(name)
595  self._seqs[name] = []
596  self._currentName = name
597  self._seq +=1
598  else:
599  # just sequenceable..
600  name = value.__str__()
601  if(self._currentName):
602  self._seqs[self._currentName].append([name, specific])
603  else:
604  self._underPath.append(value.__str__())
605  if(name not in self._done):
606  d = getParamSeqDict([], "", specific, "")
607  self._df.write(',"%s":%s'%(name,JSONFormat(d)))
608  self._done.append(name)
def getParamSeqDict
Definition: cfg-viewer.py:514
def JSONFormat
Definition: cfg-viewer.py:1264
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
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(), citk.if(), and cfg-viewer.JSONFormat().

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

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.