The Gaudi Framework  master (76fc3702)
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 164 of file ConfigurableDb.py.

164def getConfigurable(className, requester="", assumeCxxClass=True):
165 confClass = className
166 if assumeCxxClass:
167 # assume className is C++: --> translate to python
168 confClass = _normalize_cpp_type_name(confClass)
169
170 # see if I have it in my dictionary
171 confClassInfo = cfgDb.get(confClass)
172 if not confClassInfo:
173 confClassInfo = cfgDb.get(confClass)
174 # get the python module
175 confMod = confClassInfo and confClassInfo.get("module")
176 if not confMod:
177 log.warning("%s: Class %s not in database", requester, className)
178 return None
179 # load the module
180 try:
181 mod = __import__(confMod, globals(), locals(), confClass)
182 except ImportError:
183 log.warning(
184 "%s: Module %s not found (needed for configurable %s)",
185 requester,
186 confMod,
187 className,
188 )
189 return None
190 # get the class
191 try:
192 confClass = getattr(mod, confClass)
193 except AttributeError:
194 log.warning(
195 "%s: Configurable %s not found in module %s", requester, confClass, confMod
196 )
197 return None
198 # Got it!
199 log.debug("%s: Found configurable %s in module %s", requester, confClass, confMod)
200
201 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 from os.path import join as path_join
127
128 from GaudiPluginService.cpluginsvc import GAUDI_DEFAULT_PLUGIN_PATH
129
130 log.debug("loading confDb files...")
131 nFiles = 0 # counter of imported files
132 ignored_files = set(os.environ.get("CONFIGURABLE_DB_IGNORE", "").split(","))
133 for path in GAUDI_DEFAULT_PLUGIN_PATH:
134 if not path or not os.path.isdir(path):
135 continue
136 log.debug("walking in [%s]...", path)
137 confDbFiles = [
138 f
139 for f in [
140 path_join(path, f) for f in os.listdir(path) if f.endswith(".confdb")
141 ]
142 if os.path.isfile(f) and f not in ignored_files
143 ]
144 # check if we use "*_merged.confdb"
145 mergedConfDbFiles = [f for f in confDbFiles if f.endswith("_merged.confdb")]
146 if mergedConfDbFiles:
147 # use only the merged ones
148 confDbFiles = mergedConfDbFiles
149
150 for confDb in confDbFiles:
151 log.debug("\t-loading [%s]...", confDb)
152 try:
153 cfgDb._loadModule(confDb)
154 except Exception as err:
155 log.warning("Could not load file [%s] !", confDb)
156 log.warning("Reason: %s", err)
157 nFiles += 1
158 log.debug("loading confDb files... [DONE]")
159 nPkgs = len(set([k["package"] for k in cfgDb.values()]))
160 log.debug("loaded %i confDb packages", nPkgs)
161 return nFiles
162
163

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.