test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
Config Namespace Reference

Classes

class  _AndModifier
 
class  _ParameterModifier
 
class  FilteredStream
 
class  Modifier
 
class  ModifierChain
 
class  Process
 
class  ProcessFragment
 
class  ProcessModifier
 
class  SubProcess
 
class  TestMakePSet
 
class  TestModuleCommand
 

Functions

def checkImportPermission
 
def findProcess
 

Variables

tuple options = Options()
 

Function Documentation

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

References spr.find().

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

Definition at line 79 of file Config.py.

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

Variable Documentation

tuple Config.options = Options()

Definition at line 5 of file Config.py.

Referenced by helper.ConfigSectionMap().