| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.

19
20 def _fillConfDict():
21 nFiles = loadConfigurableDb()
22 log = logging.getLogger( 'PropertyProxy' )
23 log.debug( "Read module info for %d configurables from %d genConfDb files",
24 len(cfgDb), nFiles )
25 if len(cfgDb.duplicates()) > 0:
26 log.warning( "Found %d duplicates among the %d genConfDb files :",
27 len(cfgDb.duplicates()), nFiles )
28 log.warning( "--------------------------------------------------" )
29 log.warning( " -%s: %s - %s",
30 "<component name>", "<module>", "[ <duplicates> ]" )
31 log.warning( "--------------------------------------------------" )
32 dups = cfgDb.duplicates()
33 for cfgName in dups.keys():
34 log.warning( " -%s: %s - %s",
35 cfgName,
36 cfgDb[cfgName]['module'],
37 str([ d['module'] for d in dups[cfgName]]) )
38 pass
39 del dups
40 log.warning( "Fix your cmt/requirements file !!" )
41 pass
42 else:
43 log.debug( "No duplicates have been found: that's good !" )
44 pass
45 return
46
47 # fill the configurable dictionary at module load
48 _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.

54
55 def configurationDict(all=False):
56 """Return a dictionary representing the configuration.
57 The dictionary contains one entry per configurable which is a dictionary
58 with one entry per property.
59 The optional argument "all" is used to decide if to include only values
60 different from the default or all of them.
61 """
62 from GaudiKernel.Proxy.Configurable import getNeededConfigurables
63
64 catalog = allConfigurables
65 keys = getNeededConfigurables() # use only interesting configurables
66 conf_dict = {}
67 if all:
68 for n in keys :
69 if n not in conf_dict:
70 conf_dict[n] = {}
71 for p, v in catalog[n].getDefaultProperties().items() :
72 conf_dict[n][p] = v
73
74 for n in keys :
75 if n not in conf_dict:
76 conf_dict[n] = {}
77 for p, v in catalog[n].getValuedProperties().items() :
78 conf_dict[n][p] = v
79 # purge empty configurables
80 keys = conf_dict.keys()
81 for n in keys:
82 if not conf_dict[n]:
83 del conf_dict[n]
84 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.

85
86 def getConfigurable(name, defaultType = None):
87 """Helper function to get a configurable with the given name regardless
88 for the type.
89 If defaultType can be a class derived from configurable or a string. If not
90 specified, the tool name is used as type."""
91 if name in allConfigurables:
92 return allConfigurables[name]
93 else:
94 # if the configurable is not found, we need to instantiate it
95 if defaultType is None:
96 # try to use the name of the configurable as default type
97 defaultType = name
98 if type(defaultType) is str:
99 # we need to convert from string to actual class
100 if defaultType in globals():
101 # We the type is defined in the global namespace
102 defaultType = globals()[defaultType]
103 else:
104 # otherwise we try to get it from the Configurables database
105 import Configurables
106 defaultType = getattr(Configurables, defaultType)
107 return defaultType(name)

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

Definition at line 51 of file Configuration.py.

51
52 def importConfiguration(conf, local=locals()) :
53 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.

108
109 def setCustomMainLoop(runner):
110 '''
111 Replace the default main execution loop with the specified callable object.
112
113 @param runner: a callable that accepts an initialized instance of GaudiPython.AppMgr
114 and the number of events to process and returns a StatusCode or a boolean
115 (True means success)
116 '''
117 # change the mainLoop function
118 from Gaudi.Main import gaudimain
119 gaudimain.mainLoop = lambda _self, app, nevt: runner(app, nevt)
120

## 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.