CMS 3D CMS Logo

Classes | Functions | Variables
Config Namespace Reference

Classes

class  _AndModifier
 
class  _BoolModifierBase
 
class  _InvertModifier
 
class  _OrModifier
 
class  _ParameterModifier
 
class  edm
 
class  EDMException
 
class  FilteredStream
 
class  Modifier
 
class  ModifierChain
 
class  Process
 
class  ProcessAccelerator
 
class  ProcessAcceleratorTest
 
class  ProcessAcceleratorTest2
 
class  ProcessForProcessAccelerator
 
class  ProcessFragment
 
class  ProcessModifier
 
class  SubProcess
 
class  SwitchProducerTest
 
class  SwitchProducerTest2
 
class  TestMakePSet
 
class  TestModuleCommand
 
class  TestModuleTypeResolver
 

Functions

def _lineDiff (newString, oldString)
 
def _switchproducer_test2_case1 (accelerators)
 
def _switchproducer_test2_case2 (accelerators)
 
def checkImportPermission
 
def findProcess (module)
 

Variables

 options
 

Function Documentation

◆ _lineDiff()

def Config._lineDiff (   newString,
  oldString 
)
private

Definition at line 2095 of file Config.py.

References join().

Referenced by Config.TestModuleCommand.testConditionalTaskPlaceholder(), Config.TestModuleCommand.testPrefers(), Config.TestModuleCommand.testSecSource(), Config.TestModuleCommand.testSubProcess(), and Config.TestModuleCommand.testTaskPlaceholder().

2095  def _lineDiff(newString, oldString):
2096  newString = ( x for x in newString.split('\n') if len(x) > 0)
2097  oldString = [ x for x in oldString.split('\n') if len(x) > 0]
2098  diff = []
2099  oldStringLine = 0
2100  for l in newString:
2101  if oldStringLine >= len(oldString):
2102  diff.append(l)
2103  continue
2104  if l == oldString[oldStringLine]:
2105  oldStringLine +=1
2106  continue
2107  diff.append(l)
2108  return "\n".join( diff )
2109 
def _lineDiff(newString, oldString)
Definition: Config.py:2095
static std::string join(char **cmd)
Definition: RemoteFile.cc:21

◆ _switchproducer_test2_case1()

def Config._switchproducer_test2_case1 (   accelerators)
private

Definition at line 2086 of file Config.py.

2086 def _switchproducer_test2_case1(accelerators):
2087  return ("test1" in accelerators, -10)
def _switchproducer_test2_case1(accelerators)
Definition: Config.py:2086

◆ _switchproducer_test2_case2()

def Config._switchproducer_test2_case2 (   accelerators)
private

Definition at line 2088 of file Config.py.

2088 def _switchproducer_test2_case2(accelerators):
2089  return ("test2" in accelerators, -9)
2090 
def _switchproducer_test2_case2(accelerators)
Definition: Config.py:2088

◆ checkImportPermission()

def Config.checkImportPermission (   minLevel)

Definition at line 42 of file Config.py.

References spr.find().

42 def checkImportPermission(minLevel: int = 2, allowedPatterns = []):
43  """
44  Raise an exception if called by special config files. This checks
45  the call or import stack for the importing file. An exception is raised if
46  the importing module is not in allowedPatterns and if it is called too deeply:
47  minLevel = 2: inclusion by top lvel cfg only
48  minLevel = 1: No inclusion allowed
49  allowedPatterns = ['Module1','Module2/SubModule1'] allows import
50  by any module in Module1 or Submodule1
51  """
52 
53  import inspect
54  import os
55 
56  ignorePatterns = ['FWCore/ParameterSet/Config.py', 'FWCore/ParameterSet/python/Config.py','<string>','<frozen ']
57  CMSSWPath = [os.environ['CMSSW_BASE'],os.environ['CMSSW_RELEASE_BASE']]
58 
59  # Filter the stack to things in CMSSWPath and not in ignorePatterns
60  trueStack = []
61  for item in inspect.stack():
62  inPath = False
63  ignore = False
64 
65  for pattern in CMSSWPath:
66  if item[1].find(pattern) != -1:
67  inPath = True
68  break
69  if item[1].find('/') == -1: # The base file, no path
70  inPath = True
71 
72  for pattern in ignorePatterns:
73  if item[1].find(pattern) != -1:
74  ignore = True
75  break
76 
77  if inPath and not ignore:
78  trueStack.append(item[1])
79 
80  importedFile = trueStack[0]
81  importedBy = ''
82  if len(trueStack) > 1:
83  importedBy = trueStack[1]
84 
85  for pattern in allowedPatterns:
86  if importedBy.find(pattern) > -1:
87  return True
88 
89  if len(trueStack) <= minLevel: # Imported directly
90  return True
91 
92  raise ImportError("Inclusion of %s is allowed only by cfg or specified cfi files."
93  % importedFile)
94 
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
def checkImportPermission
Definition: Config.py:42

◆ findProcess()

def Config.findProcess (   module)
Look inside the module and find the Processes it contains

Definition at line 95 of file Config.py.

References default_text_conditions_cfi.object.

95 def findProcess(module):
96  """Look inside the module and find the Processes it contains"""
97  class Temp(object):
98  pass
99  process = None
100  if isinstance(module,dict):
101  if 'process' in module:
102  p = module['process']
103  module = Temp()
104  module.process = p
105  if hasattr(module,'process'):
106  if isinstance(module.process,Process):
107  process = module.process
108  else:
109  raise RuntimeError("The attribute named 'process' does not inherit from the Process class")
110  else:
111  raise RuntimeError("no 'process' attribute found in the module, please add one")
112  return process
113 
def findProcess(module)
Definition: Config.py:95

Variable Documentation

◆ options

Config.options

Definition at line 8 of file Config.py.

Referenced by helper.ConfigSectionMap().