The Gaudi Framework  v37r1 (a7f61348)
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 161 of file ConfigurableDb.py.

161 def getConfigurable(className, requester="", assumeCxxClass=True):
162  confClass = className
163  if assumeCxxClass:
164  # assume className is C++: --> translate to python
165  try:
166  confClass = str.translate(confClass, _transtable)
167  except AttributeError:
168  # Python 2 compatibility
169  confClass = string.translate(confClass, _transtable)
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()

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

Definition at line 119 of file ConfigurableDb.py.

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

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 24 of file ConfigurableDb.py.

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb

Definition at line 107 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb

Definition at line 114 of file ConfigurableDb.py.

◆ log

GaudiKernel.ConfigurableDb.log

Definition at line 31 of file ConfigurableDb.py.

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