| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

Classes | Functions | Variables

# Gaudi::Configuration Namespace Reference

## Classes
class | GaudiPersistency
## Functions
def | _fillConfDict
def | importConfiguration
def | configurationDict
def | getConfigurable
def | setCustomMainLoop
## Variables
tuple | log = logging.getLogger(__name__)
| allConfigurables = Configurable.allConfigurables

## Function Documentation

def Gaudi::Configuration::_fillConfDict | ( | ) | `[private]`

Definition at line 19 of file Configuration.py.

    00020                    :
    00021     nFiles = loadConfigurableDb()
    00022     log = logging.getLogger( 'PropertyProxy' )
    00023     log.debug( "Read module info for %d configurables from %d genConfDb files",
    00024               len(cfgDb), nFiles )
    00025     if len(cfgDb.duplicates()) > 0:
    00026         log.warning( "Found %d duplicates among the %d genConfDb files :",
    00027                      len(cfgDb.duplicates()), nFiles )
    00028         log.warning( "--------------------------------------------------" )
    00029         log.warning( "  -%s: %s - %s",
    00030                      "<component name>", "<module>", "[ <duplicates> ]" )
    00031         log.warning( "--------------------------------------------------" )
    00032         dups = cfgDb.duplicates()
    00033         for cfgName in dups.keys():
    00034             log.warning( "  -%s: %s - %s",
    00035                          cfgName,
    00036                          cfgDb[cfgName]['module'],
    00037                          str([ d['module'] for d in dups[cfgName]]) )
    00038             pass
    00039         del dups
    00040         log.warning( "Fix your cmt/requirements file !!" )
    00041         pass
    00042     else:
    00043         log.debug( "No duplicates have been found: that's good !" )
    00044         pass
    00045     return
    00046
    00047 # fill the configurable dictionary at module load
    00048 _fillConfDict()

def Gaudi::Configuration::configurationDict | ( |  | all = `False` ) |

    Return a dictionary representing the configuration.
    The dictionary contains one entry per configurable which is a dictionary
    with one entry per property.
    The optional argument "all" is used to decide if to include only values
    different from the default or all of them.

Definition at line 54 of file Configuration.py.

    00055                                 :
    00056     """Return a dictionary representing the configuration.
    00057     The dictionary contains one entry per configurable which is a dictionary
    00058     with one entry per property.
    00059     The optional argument "all" is used to decide if to include only values
    00060     different from the default or all of them.
    00061     """
    00062     from GaudiKernel.Proxy.Configurable import getNeededConfigurables
    00063
    00064     catalog = allConfigurables
    00065     keys = getNeededConfigurables() # use only interesting configurables
    00066     conf_dict = {}
    00067     if all:
    00068         for n in keys :
    00069             if n not in conf_dict:
    00070                 conf_dict[n] = {}
    00071             for p, v in  catalog[n].getDefaultProperties().items() :
    00072                 conf_dict[n][p] = v
    00073
    00074     for n in keys :
    00075         if n not in conf_dict:
    00076             conf_dict[n] = {}
    00077         for p, v in catalog[n].getValuedProperties().items() :
    00078             conf_dict[n][p] = v
    00079     # purge empty configurables
    00080     keys = conf_dict.keys()
    00081     for n in keys:
    00082         if not conf_dict[n]:
    00083             del conf_dict[n]
    00084     return conf_dict

def Gaudi::Configuration::getConfigurable | ( |  | name,
|  |  | defaultType = `None`
| ) |  |

    Helper function to get a configurable with the given name regardless
    for the type.
    If defaultType can be a class derived from configurable or a string. If not
    specified, the tool name is used as type.

Definition at line 85 of file Configuration.py.

    00086                                              :
    00087     """Helper function to get a configurable with the given name regardless
    00088     for the type.
    00089     If defaultType can be a class derived from configurable or a string. If not
    00090     specified, the tool name is used as type."""
    00091     if name in allConfigurables:
    00092         return allConfigurables[name]
    00093     else:
    00094         # if the configurable is not found, we need to instantiate it
    00095         if defaultType is None:
    00096             # try to use the name of the configurable as default type
    00097             defaultType = name
    00098         if type(defaultType) is str:
    00099             # we need to convert from string to actual class
    00100             if defaultType in globals():
    00101                 # We the type is defined in the global namespace
    00102                 defaultType = globals()[defaultType]
    00103             else:
    00104                 # otherwise we try to get it from the Configurables database
    00105                 import Configurables
    00106                 defaultType = getattr(Configurables, defaultType)
    00107         return defaultType(name)

def Gaudi::Configuration::importConfiguration | ( |  | conf,
|  |  | local = `locals()`
| ) |  |

Definition at line 51 of file Configuration.py.

    00052                                               :
    00053     local[conf] = confDbGetConfigurable(conf)

def Gaudi::Configuration::setCustomMainLoop | ( |  | runner ) |

    Replace the default main execution loop with the specified callable object.

    @param runner: a callable that accepts an initialized instance of GaudiPython.AppMgr
                   and the number of events to process and returns a StatusCode or a boolean
                   (True means success)

Definition at line 108 of file Configuration.py.

    00109                              :
    00110     '''
    00111     Replace the default main execution loop with the specified callable object.
    00112
    00113     @param runner: a callable that accepts an initialized instance of GaudiPython.AppMgr
    00114                    and the number of events to process and returns a StatusCode or a boolean
    00115                    (True means success)
    00116     '''
    00117     # change the mainLoop function
    00118     from Gaudi.Main import gaudimain
    00119     gaudimain.mainLoop = lambda _self, app, nevt: runner(app, nevt)
    00120

## Variable Documentation

Gaudi::Configuration::allConfigurables = Configurable.allConfigurables

Definition at line 17 of file Configuration.py.

tuple Gaudi::Configuration::log = logging.getLogger(__name__)

Definition at line 13 of file Configuration.py.

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