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 524 of file cfg-viewer.py.

Constructor & Destructor Documentation

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

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

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

Member Function Documentation

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

Definition at line 554 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(), and cfg-viewer.JSONFormat().

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

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

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

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

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

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

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

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

548  def _getType(self,val):
549  return re.sub(self._reg, "", str(type(val))).split(".")[-2:]
550 
def _getType(self, val)
Definition: cfg-viewer.py:548
#define str(s)
double split
Definition: MVATrainer.cc:139
def cfg-viewer.visitor.enter (   self,
  value 
)

Definition at line 578 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(), and cfg-viewer.JSONFormat().

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

Definition at line 611 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(), and cfg-viewer.JSONFormat().

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

Member Data Documentation

cfg-viewer.visitor._currentName
private

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

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

cfg-viewer.visitor._df
private

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

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

cfg-viewer.visitor._done
private

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

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

cfg-viewer.visitor._innerSeq
private

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

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

cfg-viewer.visitor._modulesToPaths
private

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

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

cfg-viewer.visitor._oldNames
private

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

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

cfg-viewer.visitor._pathLength
private

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

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

cfg-viewer.visitor._reg
private

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

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

cfg-viewer.visitor._seq
private

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

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

cfg-viewer.visitor._seqs
private

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

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

cfg-viewer.visitor._typeNumbers
private

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

cfg-viewer.visitor._underPath
private

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

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

cfg-viewer.visitor.config

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