The Gaudi Framework  v36r1 (3e2fb5a8)
CommonGaudiConfigurables.py
Go to the documentation of this file.
1 
13 """
14  This module would scan all known Gaudi configurable modules for
15  'Configurable' classes and fill __all__ such that it can be imported
16  by any module requiring it.
17 """
18 
19 from GaudiKernel.Configurable import Configurable
20 from GaudiKernel.ConfigurableMeta import ConfigurableMeta
21 __all__ = []
22 
23 packages = [
24  'GaudiCoreSvc', 'GaudiCommonSvc', 'GaudiSvc', 'GaudiAlg', 'GaudiAud',
25  'GaudiPoolDb', 'RootHistCnv', 'GaudiUtils', 'RootCnv'
26 ]
27 
28 # --Loop open all listed packages and populate __all__ with the names and
29 # the local scope with the Configurable classes
30 for package in packages:
31  try:
32  mod = __import__('%s.%sConf' % (package, package), globals(), locals(),
33  ['%sConf' % package])
34  for nam in dir(mod):
35  cls = getattr(mod, nam)
36  if type(cls) is ConfigurableMeta and issubclass(cls, Configurable):
37  globals()[nam] = cls
38  __all__.append(nam)
39  except ImportError:
40  # ignore the configurables from missing packages.
41  pass
42 
43 # --Fix some of the name idiosyncrasies in Gaudi
44 aliases = {
45  'EventDataSvc': 'EvtDataSvc',
46  'DetectorDataSvc': 'DetDataSvc',
47  'HistogramDataSvc': 'HistogramSvc',
48  'HbookHistSvc': 'HbookCnv__PersSvc',
49  'RootHistSvc': 'RootHistCnv__PersSvc',
50  'EventPersistencySvc': 'EvtPersistencySvc',
51  'DetectorPersistencySvc': 'DetPersistencySvc',
52  'HistogramPersistencySvc': 'HistogramPersistencySvc',
53  'FileRecordPersistencySvc': 'PersistencySvc',
54  'FileCatalog': 'Gaudi__MultiFileCatalog',
55  'IODataManager': 'Gaudi__IODataManager',
56  'RootCnvSvc': 'Gaudi__RootCnvSvc',
57  'RootEvtSelector': 'Gaudi__RootEvtSelector',
58 }
59 
60 _gbl = globals() # optimization
61 # This would be nicer with dict comprehension (http://www.python.org/dev/peps/pep-0274)
62 # but it is available only in Python 2.7
63 aliases = dict([(new, _gbl[old]) for new, old in aliases.items() if old in _gbl
64  ]) # do the aliasing only if the original is available
65 # change the default name
66 for new in aliases:
67  aliases[new].DefaultedName = new
68 # update globals and __all__
69 _gbl.update(aliases)
70 __all__.extend(aliases)
71 # remove temporaries
72 del _gbl
73 # The `new` var is only scoped in its `for` loop in Python 3, so we only need
74 # to 'worry' about cleanup in Python 2
75 try:
76  del new
77 except NameError:
78  pass
GaudiKernel.ConfigurableMeta
Definition: ConfigurableMeta.py:1
GaudiKernel.Configurable
Definition: Configurable.py:1
gaudirun.type
type
Definition: gaudirun.py:154