CMS 3D CMS Logo

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

Classes

class  _AndModifier
 
class  _BoolModifierBase
 
class  _InvertModifier
 
class  _OrModifier
 
class  _ParameterModifier
 
class  FilteredStream
 
class  Modifier
 
class  ModifierChain
 
class  Process
 
class  ProcessFragment
 
class  ProcessModifier
 
class  SubProcess
 
class  SwitchProducerTest
 
class  TestMakePSet
 
class  TestModuleCommand
 

Functions

def _lineDiff
 
def checkImportPermission
 
def findProcess
 

Variables

tuple options = Options()
 

Function Documentation

def Config._lineDiff (   newString,
  oldString 
)
private

Definition at line 1831 of file Config.py.

References join().

Referenced by Config.TestModuleCommand.testPrefers(), Config.TestModuleCommand.testProcessDumpPython(), Config.TestModuleCommand.testSecSource(), Config.TestModuleCommand.testSubProcess(), and Config.TestModuleCommand.testTaskPlaceholder().

1832  def _lineDiff(newString, oldString):
1833  newString = ( x for x in newString.split('\n') if len(x) > 0)
1834  oldString = [ x for x in oldString.split('\n') if len(x) > 0]
1835  diff = []
1836  oldStringLine = 0
1837  for l in newString:
1838  if oldStringLine >= len(oldString):
1839  diff.append(l)
1840  continue
1841  if l == oldString[oldStringLine]:
1842  oldStringLine +=1
1843  continue
1844  diff.append(l)
1845  return "\n".join( diff )
def _lineDiff
Definition: Config.py:1831
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
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 30 of file Config.py.

References spr.find().

30 
31 def checkImportPermission(minLevel = 2, allowedPatterns = []):
32  """
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
40  """
41 
42  import inspect
43  import os
44 
45  ignorePatterns = ['FWCore/ParameterSet/Config.py','<string>','<frozen ']
46  CMSSWPath = [os.environ['CMSSW_BASE'],os.environ['CMSSW_RELEASE_BASE']]
47 
48  # Filter the stack to things in CMSSWPath and not in ignorePatterns
49  trueStack = []
50  for item in inspect.stack():
51  inPath = False
52  ignore = False
53 
54  for pattern in CMSSWPath:
55  if item[1].find(pattern) != -1:
56  inPath = True
57  break
58  if item[1].find('/') == -1: # The base file, no path
59  inPath = True
60 
61  for pattern in ignorePatterns:
62  if item[1].find(pattern) != -1:
63  ignore = True
64  break
65 
66  if inPath and not ignore:
67  trueStack.append(item[1])
68 
69  importedFile = trueStack[0]
70  importedBy = ''
71  if len(trueStack) > 1:
72  importedBy = trueStack[1]
73 
74  for pattern in allowedPatterns:
75  if importedBy.find(pattern) > -1:
76  return True
77 
78  if len(trueStack) <= minLevel: # Imported directly
79  return True
80 
81  raise ImportError("Inclusion of %s is allowed only by cfg or specified cfi files."
82  % importedFile)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
def checkImportPermission
Definition: Config.py:30
def Config.findProcess (   module)
Look inside the module and find the Processes it contains

Definition at line 83 of file Config.py.

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

Variable Documentation

tuple Config.options = Options()

Definition at line 8 of file Config.py.

Referenced by helper.ConfigSectionMap().