44 Raise an exception if called by special config files. This checks 45 the call or import stack for the importing file. An exception is raised if 46 the importing module is not in allowedPatterns and if it is called too deeply: 47 minLevel = 2: inclusion by top lvel cfg only 48 minLevel = 1: No inclusion allowed 49 allowedPatterns = ['Module1','Module2/SubModule1'] allows import 50 by any module in Module1 or Submodule1 56 ignorePatterns = [
'FWCore/ParameterSet/Config.py',
'FWCore/ParameterSet/python/Config.py',
'<string>',
'<frozen ']
57 CMSSWPath = [os.environ[
'CMSSW_BASE'],os.environ[
'CMSSW_RELEASE_BASE']]
61 for item
in inspect.stack():
65 for pattern
in CMSSWPath:
66 if item[1].
find(pattern) != -1:
69 if item[1].
find(
'/') == -1:
72 for pattern
in ignorePatterns:
73 if item[1].
find(pattern) != -1:
77 if inPath
and not ignore:
78 trueStack.append(item[1])
80 importedFile = trueStack[0]
82 if len(trueStack) > 1:
83 importedBy = trueStack[1]
85 for pattern
in allowedPatterns:
86 if importedBy.find(pattern) > -1:
89 if len(trueStack) <= minLevel:
92 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