| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# ConfigurableDb Namespace Reference

## Classes
class | _CfgDb
class | _Singleton
## Functions
def | loadConfigurableDb
| Helper function to load all ConfigurableDb files holding informations.
def | getConfigurable
## Variables
list | __all__ = [ 'CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable' ]
tuple | _transtable = string.maketrans('<>&*,: ().', '__rp__s___')
tuple | log = logging.getLogger( 'ConfigurableDb' )
tuple | CfgDb = _Singleton()
tuple | cfgDb = CfgDb()
| default name for CfgDb instance

## Function Documentation

def ConfigurableDb::getConfigurable | ( |  | className,
|  |  | requester = `''`,
|  |  | assumeCxxClass = `True` |
| ) |  |  |

Definition at line 135 of file ConfigurableDb.py.

    00135                                                                    :
    00136     confClass=className
    00137     if assumeCxxClass:
    00138         # assume className is C++: --> translate to python
    00139         confClass = string.translate( confClass, _transtable )
    00140     # see if I have it in my dictionary
    00141     confClassInfo = cfgDb.get(confClass)
    00142     if not confClassInfo:
    00143         confClassInfo = cfgDb.get(confClass)
    00144     # get the python module
    00145     confMod = confClassInfo and confClassInfo.get('module')
    00146     if not confMod:
    00147         log.warning( "%s: Class %s not in database", requester, className )
    00148         return None
    00149     # load the module
    00150     try:
    00151         mod = __import__(confMod,globals(),locals(),confClass)
    00152     except ImportError:
    00153         log.warning( "%s: Module %s not found (needed for configurable %s)",
    00154                      requester, confMod, className )
    00155         return None
    00156     # get the class
    00157     try:
    00158         confClass = getattr(mod,confClass)
    00159     except AttributeError:
    00160         log.warning( "%s: Configurable %s not found in module %s",
    00161                      requester, confClass, confMod )
    00162         return None
    00163     # Got it!
    00164     log.debug( "%s: Found configurable %s in module %s",
    00165                requester, confClass, confMod )
    00166
    00167     return confClass
        return confClass

def ConfigurableDb::loadConfigurableDb | ( |  | ) |

Helper function to load all ConfigurableDb files holding informations.

    Helper function to load all ConfigurableDb files (modules) holding
    informations about Configurables

Definition at line 92 of file ConfigurableDb.py.

    00092                         :
    00093     """Helper function to load all ConfigurableDb files (modules) holding
    00094     informations about Configurables
    00095     """
    00096     import os
    00097     import sys
    00098     from glob import glob
    00099     from os.path import join as path_join
    00100     log.debug( "importing confDb packages..." )
    00101     nFiles = 0
    00102     for path in sys.path:
    00103         log.debug( "walking in [%s]..." % path )
    00104         if not os.path.exists(path):
    00105             continue
    00106         # speed-up: <project>_merged_confDb.py files are installed as :
    00107         # "/some/path/InstallArea/python/<project>_merged_confDb.py
    00108         # so why bother wandering in other directories ?
    00109         if not path.endswith("InstallArea"+os.sep+"python"):
    00110             continue
    00111         confDbFiles = [ f for f in glob(path_join(path, "*_merged_confDb.py"))
    00112                         if os.path.isfile(f) ]
    00113         for confDb in confDbFiles:
    00114             nFiles += 1
    00115             # turn filename syntax into module syntax: remove path+extension and replace / with . (dot)
    00116             confDbModule = os.path.splitext(confDb[len(path)+1:])[0].replace(os.sep,'.')
    00117             log.debug( "\t-importing [%s]..." % confDbModule )
    00118             try:
    00119                 mod = __import__( confDbModule )
    00120             except ImportError, err:
    00121                 log.warning( "Could not import module [%s] !", confDbModule )
    00122                 log.warning( "Reason: %s", err )
    00123                 pass
    00124             else:
    00125                 # don't need to keep the module
    00126                 del mod
    00127             pass
    00128         pass # loop over sys.path
    00129     log.debug( "importing confDb packages... [DONE]" )
    00130     nPkgs = len( set([k['package'] for k in cfgDb.values()]) )
    00131     log.debug( "imported %i confDb packages" % nPkgs )
    00132     return nFiles
    00133
    00134
    def getConfigurable( className, requester='', assumeCxxClass=True ):

## Variable Documentation

list ConfigurableDb::__all__ = [ 'CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable' ]

Definition at line 10 of file ConfigurableDb.py.

tuple ConfigurableDb::_transtable = string.maketrans('<>&*,: ().', '__rp__s___')

Definition at line 13 of file ConfigurableDb.py.

tuple ConfigurableDb::cfgDb = CfgDb()

default name for CfgDb instance

Definition at line 89 of file ConfigurableDb.py.

tuple ConfigurableDb::CfgDb = _Singleton()

Definition at line 82 of file ConfigurableDb.py.

tuple ConfigurableDb::log = logging.getLogger( 'ConfigurableDb' )

Definition at line 16 of file ConfigurableDb.py.