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  ProcessFragment
 
class  ProcessModifier
 
class  SubProcess
 
class  SwitchProducerTest
 
class  TestMakePSet
 
class  TestModuleCommand
 

Functions

def _lineDiff (newString, oldString)
 
def checkImportPermission (minLevel=2, allowedPatterns=[])
 
def findProcess (module)
 

Variables

 options
 

Function Documentation

◆ _lineDiff()

def Config._lineDiff (   newString,
  oldString 
)
private

Definition at line 1742 of file Config.py.

1742  def _lineDiff(newString, oldString):
1743  newString = ( x for x in newString.split('\n') if len(x) > 0)
1744  oldString = [ x for x in oldString.split('\n') if len(x) > 0]
1745  diff = []
1746  oldStringLine = 0
1747  for l in newString:
1748  if oldStringLine >= len(oldString):
1749  diff.append(l)
1750  continue
1751  if l == oldString[oldStringLine]:
1752  oldStringLine +=1
1753  continue
1754  diff.append(l)
1755  return "\n".join( diff )
1756 

References join().

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

◆ 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.

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','<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 

References spr.find().

◆ findProcess()

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

Definition at line 83 of file Config.py.

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 

References resolutioncreator_cfi.object.

Variable Documentation

◆ options

Config.options

Definition at line 9 of file Config.py.

Referenced by helper.ConfigSectionMap().

resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
Config.checkImportPermission
def checkImportPermission(minLevel=2, allowedPatterns=[])
Definition: Config.py:30
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Config.findProcess
def findProcess(module)
Definition: Config.py:83
Config._lineDiff
def _lineDiff(newString, oldString)
Definition: Config.py:1742