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().
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
42 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>']
43 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
47 for item
in inspect.stack():
51 for pattern
in CMSSWPath:
52 if item[1].
find(pattern) != -1:
55 if item[1].
find(
'/') == -1:
58 for pattern
in ignorePatterns:
59 if item[1].
find(pattern) != -1:
63 if inPath
and not ignore:
64 trueStack.append(item[1])
66 importedFile = trueStack[0]
68 if len(trueStack) > 1:
69 importedBy = trueStack[1]
71 for pattern
in allowedPatterns:
72 if importedBy.find(pattern) > -1:
75 if len(trueStack) <= minLevel:
78 raise ImportError(
"Inclusion of %s is allowed only by cfg or specified cfi files."
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def checkImportPermission