The Gaudi Framework  v37r1 (a7f61348)
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 # This would be nicer with dict comprehension (http://www.python.org/dev/peps/pep-0274)
71 # but it is available only in Python 2.7
72 aliases = dict(
73  [(new, _gbl[old]) for new, old in aliases.items() if old in _gbl]
74 ) # do the aliasing only if the original is available
75 # change the default name
76 for new in aliases:
77  aliases[new].DefaultedName = new
78 # update globals and __all__
79 _gbl.update(aliases)
80 __all__.extend(aliases)
81 # remove temporaries
82 del _gbl
83 # The `new` var is only scoped in its `for` loop in Python 3, so we only need
84 # to 'worry' about cleanup in Python 2
85 try:
86  del new
87 except NameError:
88  pass
GaudiKernel.ConfigurableMeta
Definition: ConfigurableMeta.py:1
GaudiKernel.Configurable
Definition: Configurable.py:1
gaudirun.type
type
Definition: gaudirun.py:162