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