| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Functions | Variables

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

    00144                                                                    :
    00145     confClass=className
    00146     if assumeCxxClass:
    00147         # assume className is C++: --> translate to python
    00148         confClass = string.translate( confClass, _transtable )
    00149     # see if I have it in my dictionary
    00150     confClassInfo = cfgDb.get(confClass)
    00151     if not confClassInfo:
    00152         confClassInfo = cfgDb.get(confClass)
    00153     # get the python module
    00154     confMod = confClassInfo and confClassInfo.get('module')
    00155     if not confMod:
    00156         log.warning( "%s: Class %s not in database", requester, className )
    00157         return None
    00158     # load the module
    00159     try:
    00160         mod = __import__(confMod,globals(),locals(),confClass)
    00161     except ImportError:
    00162         log.warning( "%s: Module %s not found (needed for configurable %s)",
    00163                      requester, confMod, className )
    00164         return None
    00165     # get the class
    00166     try:
    00167         confClass = getattr(mod,confClass)
    00168     except AttributeError:
    00169         log.warning( "%s: Configurable %s not found in module %s",
    00170                      requester, confClass, confMod )
    00171         return None
    00172     # Got it!
    00173     log.debug( "%s: Found configurable %s in module %s",
    00174                requester, confClass, confMod )
    00175
    00176     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.

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

## 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 = _Singleton()

Definition at line 82 of file ConfigurableDb.py.

tuple ConfigurableDb::cfgDb = CfgDb()

default name for CfgDb instance

Definition at line 89 of file ConfigurableDb.py.

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

Definition at line 16 of file ConfigurableDb.py.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines