The Gaudi Framework  v36r9 (fd2bdac3)
GaudiKernel.ConfigurableDb Namespace Reference

Classes

class  _CfgDb
 
class  _Singleton
 

Functions

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

Variables

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

Function Documentation

◆ getConfigurable()

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

Definition at line 164 of file ConfigurableDb.py.

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

Variable Documentation

◆ __all__

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

(c) Copyright 1998-2019 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___")
private

Definition at line 24 of file ConfigurableDb.py.

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 108 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 115 of file ConfigurableDb.py.

◆ log

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

Definition at line 31 of file ConfigurableDb.py.

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