CMS 3D CMS Logo

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

Public Member Functions

def __init__
 
def clonedTask
 
def enter
 
def leave
 

Private Member Functions

def __appendToTopTask
 
def _newLabel
 

Private Attributes

 _clonedTask
 
 _moduleLabels
 
 _noClones
 
 _postfix
 
 _process
 
 _removePostfix
 
 _verbose
 

Detailed Description

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

Definition at line 437 of file helpers.py.

Constructor & Destructor Documentation

def helpers.CloneTaskVisitor.__init__ (   self,
  process,
  label,
  postfix,
  removePostfix = "",
  noClones = [],
  verbose = False 
)

Definition at line 440 of file helpers.py.

441  def __init__(self, process, label, postfix, removePostfix="", noClones = [], verbose = False):
442  self._process = process
443  self._postfix = postfix
444  self._removePostfix = removePostfix
445  self._noClones = noClones
446  self._verbose = verbose
447  self._moduleLabels = []
448  self._clonedTask = cms.Task()
449  setattr(process, self._newLabel(label), self._clonedTask)

Member Function Documentation

def helpers.CloneTaskVisitor.__appendToTopTask (   self,
  visitee 
)
private

Definition at line 481 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

482  def __appendToTopTask(self, visitee):
483  self._clonedTask.add(visitee)
def helpers.CloneTaskVisitor._newLabel (   self,
  label 
)
private

Definition at line 473 of file helpers.py.

References helpers.CloneSequenceVisitor._postfix, helpers.CloneTaskVisitor._postfix, helpers.CloneSequenceVisitor._removePostfix, and helpers.CloneTaskVisitor._removePostfix.

Referenced by helpers.CloneTaskVisitor.enter().

474  def _newLabel(self, label):
475  if self._removePostfix != "":
476  if label[-len(self._removePostfix):] == self._removePostfix:
477  label = label[0:-len(self._removePostfix)]
478  else:
479  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
480  return label + self._postfix
def helpers.CloneTaskVisitor.clonedTask (   self)

Definition at line 467 of file helpers.py.

468  def clonedTask(self):#FIXME: can the following be used for Task?
469  for label in self._moduleLabels:
470  massSearchReplaceAnyInputTag(self._clonedTask, label, self._newLabel(label), moduleLabelOnly=True, verbose=self._verbose)
471  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedTask' function is called.
472  return self._clonedTask
def massSearchReplaceAnyInputTag
Definition: MassReplace.py:79
def helpers.CloneTaskVisitor.enter (   self,
  visitee 
)

Definition at line 450 of file helpers.py.

References helpers.CloneTaskVisitor.__appendToTopTask(), helpers.CloneSequenceVisitor._moduleLabels, helpers.CloneTaskVisitor._moduleLabels, helpers.CloneSequenceVisitor._newLabel(), helpers.CloneTaskVisitor._newLabel(), helpers.CloneSequenceVisitor._noClones, helpers.CloneTaskVisitor._noClones, helpers.CloneSequenceVisitor._process, and helpers.CloneTaskVisitor._process.

451  def enter(self, visitee):
452  if isinstance(visitee, cms._Module):
453  label = visitee.label()
454  newModule = None
455  if label in self._noClones: #keep unchanged
456  newModule = getattr(self._process, label)
457  elif label in self._moduleLabels: # has the module already been cloned ?
458  newModule = getattr(self._process, self._newLabel(label))
459  else:
460  self._moduleLabels.append(label)
461  newModule = visitee.clone()
462  setattr(self._process, self._newLabel(label), newModule)
463  self.__appendToTopTask(newModule)
def helpers.CloneTaskVisitor.leave (   self,
  visitee 
)

Definition at line 464 of file helpers.py.

465  def leave(self, visitee):
466  pass

Member Data Documentation

helpers.CloneTaskVisitor._clonedTask
private

Definition at line 447 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.clonedTask().

helpers.CloneTaskVisitor._moduleLabels
private

Definition at line 446 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.clonedTask(), and helpers.CloneTaskVisitor.enter().

helpers.CloneTaskVisitor._noClones
private

Definition at line 444 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

helpers.CloneTaskVisitor._postfix
private

Definition at line 442 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

helpers.CloneTaskVisitor._process
private

Definition at line 441 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

helpers.CloneTaskVisitor._removePostfix
private

Definition at line 443 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

helpers.CloneTaskVisitor._verbose
private

Definition at line 445 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.clonedTask().