Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CommonGaudiConfigurables.py
Go to the documentation of this file.
1 # File: Gaudi/CommonGaudiConfigurables.py
2 # Author: Pere Mato (pere.mato@cern.ch)
3 """
4  This module would scan all known Gaudi configurable modules for
5  'Configurable' classes and fill __all__ such that it can be imported
6  by any module requiring it.
7 """
8 
9 from GaudiKernel.Configurable import Configurable
10 from GaudiKernel.ConfigurableMeta import ConfigurableMeta
11 __all__ = []
12 
13 packages = [
14  'GaudiCoreSvc', 'GaudiCommonSvc', 'GaudiSvc', 'GaudiAlg', 'GaudiAud',
15  'GaudiPoolDb', 'RootHistCnv', 'GaudiUtils', 'RootCnv'
16 ]
17 
18 # --Loop open all listed packages and populate __all__ with the names and
19 # the local scope with the Configurable classes
20 for package in packages:
21  try:
22  mod = __import__('%s.%sConf' % (package, package), globals(), locals(),
23  ['%sConf' % package])
24  for nam in dir(mod):
25  cls = getattr(mod, nam)
26  if type(cls) is ConfigurableMeta and issubclass(cls, Configurable):
27  globals()[nam] = cls
28  __all__.append(nam)
29  except ImportError:
30  # ignore the configurables from missing packages.
31  pass
32 
33 # --Fix some of the name idiosyncrasies in Gaudi
34 aliases = {
35  'EventDataSvc': 'EvtDataSvc',
36  'DetectorDataSvc': 'DetDataSvc',
37  'HistogramDataSvc': 'HistogramSvc',
38  'HbookHistSvc': 'HbookCnv__PersSvc',
39  'RootHistSvc': 'RootHistCnv__PersSvc',
40  'EventPersistencySvc': 'EvtPersistencySvc',
41  'DetectorPersistencySvc': 'DetPersistencySvc',
42  'HistogramPersistencySvc': 'HistogramPersistencySvc',
43  'FileRecordPersistencySvc': 'PersistencySvc',
44  'FileCatalog': 'Gaudi__MultiFileCatalog',
45  'IODataManager': 'Gaudi__IODataManager',
46  'RootCnvSvc': 'Gaudi__RootCnvSvc',
47  'RootEvtSelector': 'Gaudi__RootEvtSelector',
48 }
49 
50 _gbl = globals() # optimization
51 # This would be nicer with dict comprehension (http://www.python.org/dev/peps/pep-0274)
52 # but it is available only in Python 2.7
53 aliases = dict([(new, _gbl[old]) for new, old in aliases.items() if old in _gbl
54  ]) # do the aliasing only if the original is available
55 # change the default name
56 for new in aliases:
57  aliases[new].DefaultedName = new
58 # update globals and __all__
59 _gbl.update(aliases)
60 __all__.extend(aliases)
61 # remove temporaries
62 del _gbl, new