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  FilteredStream
 
class  Process
 
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 27 of file Config.py.

References spr.find().

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

Definition at line 80 of file Config.py.

References dbtoconf.object.

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

Variable Documentation

tuple Config.options = Options()

Definition at line 5 of file Config.py.