The Gaudi Framework  master (37c0b60a)
GaudiKernel.ConfigurableDb Namespace Reference

Classes

class  _CfgDb
 
class  _Singleton
 

Functions

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

Variables

 __all__
 (c) Copyright 1998-2023 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". More...
 
 _transtable
 
 log
 
 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  confClass = str.translate(confClass, _transtable)
160 
161  # see if I have it in my dictionary
162  confClassInfo = cfgDb.get(confClass)
163  if not confClassInfo:
164  confClassInfo = cfgDb.get(confClass)
165  # get the python module
166  confMod = confClassInfo and confClassInfo.get("module")
167  if not confMod:
168  log.warning("%s: Class %s not in database", requester, className)
169  return None
170  # load the module
171  try:
172  mod = __import__(confMod, globals(), locals(), confClass)
173  except ImportError:
174  log.warning(
175  "%s: Module %s not found (needed for configurable %s)",
176  requester,
177  confMod,
178  className,
179  )
180  return None
181  # get the class
182  try:
183  confClass = getattr(mod, confClass)
184  except AttributeError:
185  log.warning(
186  "%s: Configurable %s not found in module %s", requester, confClass, confMod
187  )
188  return None
189  # Got it!
190  log.debug("%s: Found configurable %s in module %s", requester, confClass, confMod)
191 
192  return confClass

◆ loadConfigurableDb()

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

Definition at line 113 of file ConfigurableDb.py.

113 def 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("LD_LIBRARY_PATH", "").split(os.pathsep)
123  ignored_files = set(os.environ.get("CONFIGURABLE_DB_IGNORE", "").split(","))
124  for path in pathlist:
125  if not os.path.isdir(path):
126  continue
127  log.debug("walking in [%s]...", path)
128  confDbFiles = [
129  f
130  for f in [
131  path_join(path, f) for f in os.listdir(path) if f.endswith(".confdb")
132  ]
133  if os.path.isfile(f) and f not in ignored_files
134  ]
135  # check if we use "*_merged.confdb"
136  mergedConfDbFiles = [f for f in confDbFiles if f.endswith("_merged.confdb")]
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 

Variable Documentation

◆ __all__

GaudiKernel.ConfigurableDb.__all__
private

(c) Copyright 1998-2023 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
private

Definition at line 23 of file ConfigurableDb.py.

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb

Definition at line 101 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb

Definition at line 108 of file ConfigurableDb.py.

◆ log

GaudiKernel.ConfigurableDb.log

Definition at line 25 of file ConfigurableDb.py.

GaudiKernel.ConfigurableDb.getConfigurable
def getConfigurable(className, requester="", assumeCxxClass=True)
Definition: ConfigurableDb.py:155
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:113