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

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

References spr.find().

◆ findProcess()

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

Definition at line 82 of file Config.py.

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

References resolutioncreator_cfi.object.

Variable Documentation

◆ options

Config.options

Definition at line 8 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:29
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:82
Config._lineDiff
def _lineDiff(newString, oldString)
Definition: Config.py:1742