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.
References spr.find().
33 Raise an exception if called by special config files. This checks
34 the call or import stack for the importing file. An exception is raised if
35 the importing module is not in allowedPatterns and if it is called too deeply:
36 minLevel = 2: inclusion by top lvel cfg only
37 minLevel = 1: No inclusion allowed
38 allowedPatterns = ['Module1','Module2/SubModule1'] allows import
39 by any module in Module1 or Submodule1
45 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'<string>',
'<frozen ']
46 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
50 for item
in inspect.stack():
54 for pattern
in CMSSWPath:
55 if item[1].
find(pattern) != -1:
58 if item[1].
find(
'/') == -1:
61 for pattern
in ignorePatterns:
62 if item[1].
find(pattern) != -1:
66 if inPath
and not ignore:
67 trueStack.append(item[1])
69 importedFile = trueStack[0]
71 if len(trueStack) > 1:
72 importedBy = trueStack[1]
74 for pattern
in allowedPatterns:
75 if importedBy.find(pattern) > -1:
78 if len(trueStack) <= minLevel:
81 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