CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

helpers::CloneSequenceVisitor Class Reference

List of all members.

Public Member Functions

def __init__
def clonedSequence
def enter
def leave

Private Member Functions

def __appendToTopSequence
def _newLabel

Private Attributes

 _clonedSequence
 _moduleLabels
 _postfix
 _process
 _removePostfix

Detailed Description

Visitor that travels within a cms.Sequence, and returns a cloned version of the Sequence.
All modules and sequences are cloned and a postfix is added

Definition at line 128 of file helpers.py.


Constructor & Destructor Documentation

def helpers::CloneSequenceVisitor::__init__ (   self,
  process,
  label,
  postfix,
  removePostfix = "" 
)

Definition at line 131 of file helpers.py.

00132                                                                  :
00133         self._process = process
00134         self._postfix = postfix
00135         self._removePostfix = removePostfix
00136         self._moduleLabels = []
00137         self._clonedSequence = cms.Sequence()
00138         setattr(process, self._newLabel(label), self._clonedSequence)


Member Function Documentation

def helpers::CloneSequenceVisitor::__appendToTopSequence (   self,
  visitee 
) [private]

Definition at line 168 of file helpers.py.

00169                                             :
00170         self._clonedSequence += visitee
        
def helpers::CloneSequenceVisitor::_newLabel (   self,
  label 
) [private]

Definition at line 160 of file helpers.py.

00161                               :
00162         if self._removePostfix != "":
00163             if label[-len(self._removePostfix):] == self._removePostfix:
00164                 label = label[0:-len(self._removePostfix)]
00165             else:
00166                 raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
00167         return label + self._postfix

def helpers::CloneSequenceVisitor::clonedSequence (   self)

Definition at line 154 of file helpers.py.

00155                             :
00156         for label in self._moduleLabels:
00157             massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=False)
00158         self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
00159         return self._clonedSequence

def helpers::CloneSequenceVisitor::enter (   self,
  visitee 
)

Definition at line 139 of file helpers.py.

00140                             :
00141         if isinstance(visitee, cms._Module):
00142             label = visitee.label()
00143             newModule = None
00144             if label in self._moduleLabels: # has the module already been cloned ?
00145                 newModule = getattr(self._process, self._newLabel(label))
00146             else:
00147                 self._moduleLabels.append(label)                
00148                 newModule = visitee.clone()
00149                 setattr(self._process, self._newLabel(label), newModule)
00150             self.__appendToTopSequence(newModule)

def helpers::CloneSequenceVisitor::leave (   self,
  visitee 
)

Definition at line 151 of file helpers.py.

00152                             :
00153         pass


Member Data Documentation

Definition at line 131 of file helpers.py.

Definition at line 131 of file helpers.py.

Definition at line 131 of file helpers.py.

Definition at line 131 of file helpers.py.

Definition at line 131 of file helpers.py.