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