| The Gaudi Framework v32r1 (f65d50dc)

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 = str.maketrans('<>&*,: ().', '__rp__s___')
| log = logging.getLogger('ConfigurableDb')
| CfgDb = _Singleton()
| cfgDb = CfgDb()

## Function Documentation

## ◆ getConfigurable()

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

Definition at line 155 of file ConfigurableDb.py.

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

## ◆ loadConfigurableDb()

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

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

Definition at line 109 of file ConfigurableDb.py.

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

## Variable Documentation

## ◆ __all__

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

Definition at line 9 of file ConfigurableDb.py.

## ◆ _transtable

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

Definition at line 13 of file ConfigurableDb.py.

## ◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 97 of file ConfigurableDb.py.

## ◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 104 of file ConfigurableDb.py.

## ◆ log

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

Definition at line 19 of file ConfigurableDb.py.