CMS 3D CMS Logo

Classes | Functions | Variables
Config Namespace Reference

Classes

class  _AndModifier
 
class  _BoolModifierBase
 
class  _InvertModifier
 
class  _OrModifier
 
class  _ParameterModifier
 
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
 

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 2021 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().

2021  def _lineDiff(newString, oldString):
2022  newString = ( x for x in newString.split('\n') if len(x) > 0)
2023  oldString = [ x for x in oldString.split('\n') if len(x) > 0]
2024  diff = []
2025  oldStringLine = 0
2026  for l in newString:
2027  if oldStringLine >= len(oldString):
2028  diff.append(l)
2029  continue
2030  if l == oldString[oldStringLine]:
2031  oldStringLine +=1
2032  continue
2033  diff.append(l)
2034  return "\n".join( diff )
2035 
def _lineDiff(newString, oldString)
Definition: Config.py:2021
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ _switchproducer_test2_case1()

def Config._switchproducer_test2_case1 (   accelerators)
private

Definition at line 2012 of file Config.py.

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

◆ _switchproducer_test2_case2()

def Config._switchproducer_test2_case2 (   accelerators)
private

Definition at line 2014 of file Config.py.

2014 def _switchproducer_test2_case2(accelerators):
2015  return ("test2" in accelerators, -9)
2016 
def _switchproducer_test2_case2(accelerators)
Definition: Config.py:2014

◆ 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 30 of file Config.py.

References spr.find().

30 def checkImportPermission(minLevel = 2, allowedPatterns = []):
31  """
32  Raise an exception if called by special config files. This checks
33  the call or import stack for the importing file. An exception is raised if
34  the importing module is not in allowedPatterns and if it is called too deeply:
35  minLevel = 2: inclusion by top lvel cfg only
36  minLevel = 1: No inclusion allowed
37  allowedPatterns = ['Module1','Module2/SubModule1'] allows import
38  by any module in Module1 or Submodule1
39  """
40 
41  import inspect
42  import os
43 
44  ignorePatterns = ['FWCore/ParameterSet/Config.py', 'FWCore/ParameterSet/python/Config.py','<string>','<frozen ']
45  CMSSWPath = [os.environ['CMSSW_BASE'],os.environ['CMSSW_RELEASE_BASE']]
46 
47  # Filter the stack to things in CMSSWPath and not in ignorePatterns
48  trueStack = []
49  for item in inspect.stack():
50  inPath = False
51  ignore = False
52 
53  for pattern in CMSSWPath:
54  if item[1].find(pattern) != -1:
55  inPath = True
56  break
57  if item[1].find('/') == -1: # The base file, no path
58  inPath = True
59 
60  for pattern in ignorePatterns:
61  if item[1].find(pattern) != -1:
62  ignore = True
63  break
64 
65  if inPath and not ignore:
66  trueStack.append(item[1])
67 
68  importedFile = trueStack[0]
69  importedBy = ''
70  if len(trueStack) > 1:
71  importedBy = trueStack[1]
72 
73  for pattern in allowedPatterns:
74  if importedBy.find(pattern) > -1:
75  return True
76 
77  if len(trueStack) <= minLevel: # Imported directly
78  return True
79 
80  raise ImportError("Inclusion of %s is allowed only by cfg or specified cfi files."
81  % importedFile)
82 
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:30

◆ findProcess()

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

Definition at line 83 of file Config.py.

References resolutioncreator_cfi.object.

83 def findProcess(module):
84  """Look inside the module and find the Processes it contains"""
85  class Temp(object):
86  pass
87  process = None
88  if isinstance(module,dict):
89  if 'process' in module:
90  p = module['process']
91  module = Temp()
92  module.process = p
93  if hasattr(module,'process'):
94  if isinstance(module.process,Process):
95  process = module.process
96  else:
97  raise RuntimeError("The attribute named 'process' does not inherit from the Process class")
98  else:
99  raise RuntimeError("no 'process' attribute found in the module, please add one")
100  return process
101 
def findProcess(module)
Definition: Config.py:83

Variable Documentation

◆ options

Config.options

Definition at line 8 of file Config.py.

Referenced by helper.ConfigSectionMap().