| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Classes | Functions | Variables
GaudiKernel.ConfigurableDb Namespace Reference

## Classes
class | _CfgDb
class | _Singleton

## Functions
def | loadConfigurableDb ()
def | getConfigurable (className, requester='', assumeCxxClass=True)

## Variables
list | __all__ = ['CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable']
| _transtable = string.maketrans('<>&*,: ().', '__rp__s___')
| log = logging.getLogger('ConfigurableDb')
| CfgDb = _Singleton()
| cfgDb = CfgDb()

## Function Documentation

def GaudiKernel.ConfigurableDb.getConfigurable | ( |  | className,
|  |  | requester = `''`,
|  |  | assumeCxxClass = `True`
| ) |  |

Definition at line 152 of file ConfigurableDb.py.

152 def getConfigurable(className, requester='', assumeCxxClass=True):
153 confClass = className
154 if assumeCxxClass:
155 # assume className is C++: --> translate to python
156 confClass = string.translate(confClass, _transtable)
157 # see if I have it in my dictionary
158 confClassInfo = cfgDb.get(confClass)
159 if not confClassInfo:
160 confClassInfo = cfgDb.get(confClass)
161 # get the python module
162 confMod = confClassInfo and confClassInfo.get('module')
163 if not confMod:
164 log.warning("%s: Class %s not in database", requester, className)
165 return None
166 # load the module
167 try:
168 mod = __import__(confMod, globals(), locals(), confClass)
169 except ImportError:
170 log.warning("%s: Module %s not found (needed for configurable %s)",
171 requester, confMod, className)
172 return None
173 # get the class
174 try:
175 confClass = getattr(mod, confClass)
176 except AttributeError:
177 log.warning("%s: Configurable %s not found in module %s",
178 requester, confClass, confMod)
179 return None
180 # Got it!
181 log.debug("%s: Found configurable %s in module %s",
182 requester, confClass, confMod)
183
184 return confClass
185
GaudiKernel.ConfigurableDb.getConfigurable
def getConfigurable(className, requester='', assumeCxxClass=True)
Definition: ConfigurableDb.py:152

def GaudiKernel.ConfigurableDb.loadConfigurableDb | ( |  | ) |

    Helper function to load all ConfigurableDb files (modules) holding
    informations about Configurables

Definition at line 110 of file ConfigurableDb.py.

110 def loadConfigurableDb():
111 """Helper function to load all ConfigurableDb files (modules) holding
112 informations about Configurables
113 """
114 import os
115 import sys
116 from glob import glob
117 from os.path import join as path_join
118 log.debug("loading confDb files...")
119 nFiles = 0 # counter of imported files
120 if sys.platform == 'darwin':
121 pathlist = os.getenv("DYLD_LIBRARY_PATH", "").split(os.pathsep)
122 else:
123 pathlist = os.getenv("LD_LIBRARY_PATH", "").split(os.pathsep)
124 for path in pathlist:
125 if not os.path.isdir(path):
126 continue
127 log.debug("walking in [%s]...", path)
128 confDbFiles = [f for f in [path_join(path, f) for f in os.listdir(path)
129 if f.endswith('.confdb')]
130 if os.path.isfile(f)]
131 # check if we use "*_merged.confdb"
132 mergedConfDbFiles = [f for f in confDbFiles
133 if f.endswith('_merged.confdb')]
134 if mergedConfDbFiles:
135 # use only the merged ones
136 confDbFiles = mergedConfDbFiles
137
138 for confDb in confDbFiles:
139 log.debug("\t-loading [%s]...", confDb)
140 try:
141 cfgDb._loadModule(confDb)
142 except Exception, err:
143 log.warning("Could not load file [%s] !", confDb)
144 log.warning("Reason: %s", err)
145 nFiles += 1
146 log.debug("loading confDb files... [DONE]")
147 nPkgs = len(set([k['package'] for k in cfgDb.values()]))
148 log.debug("loaded %i confDb packages", nPkgs)
149 return nFiles
150
151
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:110

## Variable Documentation

list GaudiKernel.ConfigurableDb.__all__ = ['CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable']
| private

Definition at line 10 of file ConfigurableDb.py.

GaudiKernel.ConfigurableDb._transtable = string.maketrans('<>&*,: ().', '__rp__s___')
| private

Definition at line 13 of file ConfigurableDb.py.

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 98 of file ConfigurableDb.py.

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 105 of file ConfigurableDb.py.

GaudiKernel.ConfigurableDb.log = logging.getLogger('ConfigurableDb')

Definition at line 16 of file ConfigurableDb.py.