The Gaudi Framework  master (da3d77e1)
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 
22 __all__ = []
23 
24 packages = [
25  "GaudiCoreSvc",
26  "GaudiCommonSvc",
27  "GaudiSvc",
28  "GaudiAud",
29  "GaudiPoolDb",
30  "RootHistCnv",
31  "GaudiUtils",
32  "RootCnv",
33 ]
34 
35 # --Loop open all listed packages and populate __all__ with the names and
36 # the local scope with the Configurable classes
37 for package in packages:
38  try:
39  mod = __import__(
40  "%s.%sConf" % (package, package), globals(), locals(), ["%sConf" % package]
41  )
42  for nam in dir(mod):
43  cls = getattr(mod, nam)
44  if type(cls) is ConfigurableMeta and issubclass(cls, Configurable):
45  globals()[nam] = cls
46  __all__.append(nam)
47  except ImportError:
48  # ignore the configurables from missing packages.
49  pass
50 
51 # --Fix some of the name idiosyncrasies in Gaudi
52 aliases = {
53  "EventDataSvc": "EvtDataSvc",
54  "DetectorDataSvc": "DetDataSvc",
55  "HistogramDataSvc": "HistogramSvc",
56  "HbookHistSvc": "HbookCnv__PersSvc",
57  "RootHistSvc": "RootHistCnv__PersSvc",
58  "EventPersistencySvc": "EvtPersistencySvc",
59  "DetectorPersistencySvc": "DetPersistencySvc",
60  "HistogramPersistencySvc": "HistogramPersistencySvc",
61  "FileRecordPersistencySvc": "PersistencySvc",
62  "FileCatalog": "Gaudi__MultiFileCatalog",
63  "IODataManager": "Gaudi__IODataManager",
64  "RootCnvSvc": "Gaudi__RootCnvSvc",
65  "RootEvtSelector": "Gaudi__RootEvtSelector",
66 }
67 
68 _gbl = globals() # optimization
69 
70 # do the aliasing only if the original is available
71 aliases = {new: _gbl[old] for new, old in aliases.items() if old in _gbl}
72 
73 # change the default name
74 for new in aliases:
75  aliases[new].DefaultedName = new
76 # update globals and __all__
77 _gbl.update(aliases)
78 __all__.extend(aliases)
79 # remove temporaries
80 del _gbl
81 try:
82  del new # only available if len(aliases)>0
83 except NameError:
84  pass
GaudiKernel.ConfigurableMeta
Definition: ConfigurableMeta.py:1
GaudiKernel.Configurable
Definition: Configurable.py:1
gaudirun.type
type
Definition: gaudirun.py:160