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 (minLevel=2, allowedPatterns=[])
 
def findProcess (module)
 

Variables

 options
 

Function Documentation

◆ _lineDiff()

def Config._lineDiff (   newString,
  oldString 
)
private

Definition at line 2094 of file Config.py.

References join().

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

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

◆ _switchproducer_test2_case1()

def Config._switchproducer_test2_case1 (   accelerators)
private

Definition at line 2085 of file Config.py.

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

◆ _switchproducer_test2_case2()

def Config._switchproducer_test2_case2 (   accelerators)
private

Definition at line 2087 of file Config.py.

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

◆ checkImportPermission()

def Config.checkImportPermission (   minLevel = 2,
  allowedPatterns = [] 
)
Raise an exception if called by special config files. This checks
the call or import stack for the importing file. An exception is raised if
the importing module is not in allowedPatterns and if it is called too deeply:
minLevel = 2: inclusion by top lvel cfg only
minLevel = 1: No inclusion allowed
allowedPatterns = ['Module1','Module2/SubModule1'] allows import
by any module in Module1 or Submodule1

Definition at line 41 of file Config.py.

References spr.find().

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

◆ findProcess()

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

Definition at line 94 of file Config.py.

References resolutioncreator_cfi.object.

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

Variable Documentation

◆ options

Config.options

Definition at line 8 of file Config.py.

Referenced by helper.ConfigSectionMap().