The Gaudi Framework  master (82fdf313)
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 "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
37for 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
52aliases = {
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
71aliases = {new: _gbl[old] for new, old in aliases.items() if old in _gbl}
72
73# change the default name
74for new in aliases:
75 aliases[new].DefaultedName = new
76# update globals and __all__
77_gbl.update(aliases)
78__all__.extend(aliases)
79# remove temporaries
80del _gbl
81try:
82 del new # only available if len(aliases)>0
83except NameError:
84 pass