The Gaudi Framework  master (69a68366)
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 165 of file ConfigurableDb.py.

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

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.