The Gaudi Framework  v36r13 (995e4364)
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 162 of file ConfigurableDb.py.

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

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

Definition at line 120 of file ConfigurableDb.py.

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

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

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb

Definition at line 115 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:162
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:120