The Gaudi Framework  v36r1 (3e2fb5a8)
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 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("%s: Module %s not found (needed for configurable %s)",
185  requester, confMod, className)
186  return None
187  # get the class
188  try:
189  confClass = getattr(mod, confClass)
190  except AttributeError:
191  log.warning("%s: Configurable %s not found in module %s", requester,
192  confClass, confMod)
193  return None
194  # Got it!
195  log.debug("%s: Found configurable %s in module %s", requester, confClass,
196  confMod)
197 
198  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  import sys
125  from glob import glob
126  from os.path import join as path_join
127  log.debug("loading confDb files...")
128  nFiles = 0 # counter of imported files
129  pathlist = os.getenv("LD_LIBRARY_PATH", "").split(os.pathsep)
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 for f in [
136  path_join(path, f) for f in os.listdir(path)
137  if f.endswith('.confdb')
138  ] if os.path.isfile(f)
139  ]
140  # check if we use "*_merged.confdb"
141  mergedConfDbFiles = [
142  f for f in confDbFiles if f.endswith('_merged.confdb')
143  ]
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__

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

◆ CfgDb

GaudiKernel.ConfigurableDb.CfgDb = _Singleton()

Definition at line 107 of file ConfigurableDb.py.

◆ cfgDb

GaudiKernel.ConfigurableDb.cfgDb = CfgDb()

Definition at line 114 of file ConfigurableDb.py.

◆ log

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

Definition at line 29 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:119