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

Classes

class  _CfgDb
 
class  _Singleton
 

Functions

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

Variables

list __all__ = ["CfgDb", "cfgDb", "loadConfigurableDb", "getConfigurable"]
 (c) Copyright 1998-2025 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".
 
 _transtable = str.maketrans("<>&*,: ().", "__rp__s___")
 
 log = logging.getLogger("ConfigurableDb")
 
 CfgDb = _Singleton()
 
 cfgDb = CfgDb()
 

Function Documentation

◆ getConfigurable()

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

Definition at line 157 of file ConfigurableDb.py.

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

◆ loadConfigurableDb()

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

Definition at line 113 of file ConfigurableDb.py.

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

Variable Documentation

◆ __all__

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

(c) Copyright 1998-2025 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.

◆ _transtable

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

Definition at line 23 of file ConfigurableDb.py.

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 101 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 108 of file ConfigurableDb.py.

◆ log

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

Definition at line 25 of file ConfigurableDb.py.