The Gaudi Framework  master (766b6f4b)
Loading...
Searching...
No Matches
GaudiKernel.ConfigurableDb Namespace Reference

Classes

class  _CfgDb
 
class  _Singleton
 

Functions

 _normalize_cpp_type_name (name)
 
 loadConfigurableDb ()
 
 getConfigurable (className, requester="", assumeCxxClass=True)
 

Variables

list __all__ = ["CfgDb", "cfgDb", "loadConfigurableDb", "getConfigurable"]
 (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".
 
 log = logging.getLogger("ConfigurableDb")
 
 _TRANS_TABLE = str.maketrans("<>&*,: ().", "__rp__s___")
 
 CfgDb = _Singleton()
 
 cfgDb = CfgDb()
 

Function Documentation

◆ _normalize_cpp_type_name()

GaudiKernel.ConfigurableDb._normalize_cpp_type_name ( name)
protected
Translate a C++ type name (with templates etc.) to Python identifier.

Definition at line 29 of file ConfigurableDb.py.

29def _normalize_cpp_type_name(name):
30 """
31 Translate a C++ type name (with templates etc.) to Python identifier.
32 """
33 return name.replace(", ", ",").translate(_TRANS_TABLE)
34
35

◆ getConfigurable()

GaudiKernel.ConfigurableDb.getConfigurable ( className,
requester = "",
assumeCxxClass = True )

Definition at line 174 of file ConfigurableDb.py.

174def getConfigurable(className, requester="", assumeCxxClass=True):
175 confClass = className
176 if assumeCxxClass:
177 # assume className is C++: --> translate to python
178 confClass = _normalize_cpp_type_name(confClass)
179
180 # see if I have it in my dictionary
181 confClassInfo = cfgDb.get(confClass)
182 if not confClassInfo:
183 confClassInfo = cfgDb.get(confClass)
184 # get the python module
185 confMod = confClassInfo and confClassInfo.get("module")
186 if not confMod:
187 log.warning("%s: Class %s not in database", requester, className)
188 return None
189 # load the module
190 try:
191 mod = __import__(confMod, globals(), locals(), confClass)
192 except ImportError:
193 log.warning(
194 "%s: Module %s not found (needed for configurable %s)",
195 requester,
196 confMod,
197 className,
198 )
199 return None
200 # get the class
201 try:
202 confClass = getattr(mod, confClass)
203 except AttributeError:
204 log.warning(
205 "%s: Configurable %s not found in module %s", requester, confClass, confMod
206 )
207 return None
208 # Got it!
209 log.debug("%s: Found configurable %s in module %s", requester, confClass, confMod)
210
211 return confClass

◆ loadConfigurableDb()

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

Definition at line 121 of file ConfigurableDb.py.

121def loadConfigurableDb():
122 """Helper function to load all ConfigurableDb files (modules) holding
123 informations about Configurables
124 """
125 import os
126 import sys
127 from itertools import chain
128 from os.path import join as path_join
129
130 from GaudiPluginService.cpluginsvc import GAUDI_DEFAULT_PLUGIN_PATH
131
132 log.debug("loading confDb files...")
133 nFiles = 0 # counter of imported files
134 pathvars = (
135 ["GAUDI_PLUGIN_PATH", "DYLD_LIBRARY_PATH"]
136 if sys.platform == "darwin"
137 else ["GAUDI_PLUGIN_PATH", "LD_LIBRARY_PATH"]
138 )
139 ignored_files = set(os.environ.get("CONFIGURABLE_DB_IGNORE", "").split(","))
140 for path in chain(
141 [GAUDI_DEFAULT_PLUGIN_PATH],
142 *[os.getenv(pv, "").split(os.pathsep) for pv in pathvars],
143 ):
144 if not path or not os.path.isdir(path):
145 continue
146 log.debug("walking in [%s]...", path)
147 confDbFiles = [
148 f
149 for f in [
150 path_join(path, f) for f in os.listdir(path) if f.endswith(".confdb")
151 ]
152 if os.path.isfile(f) and f not in ignored_files
153 ]
154 # check if we use "*_merged.confdb"
155 mergedConfDbFiles = [f for f in confDbFiles if f.endswith("_merged.confdb")]
156 if mergedConfDbFiles:
157 # use only the merged ones
158 confDbFiles = mergedConfDbFiles
159
160 for confDb in confDbFiles:
161 log.debug("\t-loading [%s]...", confDb)
162 try:
163 cfgDb._loadModule(confDb)
164 except Exception as err:
165 log.warning("Could not load file [%s] !", confDb)
166 log.warning("Reason: %s", err)
167 nFiles += 1
168 log.debug("loading confDb files... [DONE]")
169 nPkgs = len(set([k["package"] for k in cfgDb.values()]))
170 log.debug("loaded %i confDb packages", nPkgs)
171 return nFiles
172
173

Variable Documentation

◆ __all__

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

(c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".

# # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. #

File: AthenaCommon/python/ConfigurableDb.py Author: Sebastien Binet (binet.nosp@m.@cer.nosp@m.n.ch)

Definition at line 19 of file ConfigurableDb.py.

◆ _TRANS_TABLE

GaudiKernel.ConfigurableDb._TRANS_TABLE = str.maketrans("<>&*,: ().", "__rp__s___")
protected

Definition at line 26 of file ConfigurableDb.py.

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 109 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 116 of file ConfigurableDb.py.

◆ log

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

Definition at line 23 of file ConfigurableDb.py.