ATLAS Offline Software
CfgMgr.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 # @file: AthenaCommon/python/CfgMgr.py
4 # @purpose: facade to Configurables
5 # @author: Sebastien Binet <binet@cern.ch>
6 
7 __author__ = "Sebastien Binet <binet@cern.ch>"
8 __version__ = "$Revision: 1.3 $"
9 __doc__ = """
10 A module facade to the repository of automatically generated configurables.
11 Once imported it allows queries like so:
12  >>> from AthenaCommon import CfgMgr
13  >>> topSequence += CfgMgr.MyAlgorithm( 'MyAlg', OutputLevel = INFO )
14  >>> topSequence += CfgMgr.MyCppNs__MyAlgorithm( 'UrAlg' )
15 """
16 
17 import sys
18 import types
19 
20 class ModuleFacade(types.ModuleType):
21  """a helper class to allow easy retrieval of automatically generated
22  configurables (stolen from PyRoot)
23  """
24  def __init__( self, module ):
25  types.ModuleType.__init__( self, __name__ )
26 
27  self.__dict__[ '__doc__' ] = module.__doc__
28  self.__dict__[ '__name__' ] = module.__name__
29 
30  from AthenaCommon.ConfigurableDb import getConfigurable
31  self.__dict__[ 'getConfigurable' ] = getConfigurable
32 
33  def __getattr__(self, k):
34  if not k.startswith( '__' ):
35  return self.getConfigurable( k, assumeCxxClass = False )
36 
37  return super( types.ModuleType, self ).__getattr__( self, k )
38 
39 sys.modules[ __name__ ] = ModuleFacade( sys.modules[ __name__ ] )
40 del ModuleFacade
python.CfgMgr.ModuleFacade.__getattr__
def __getattr__(self, k)
Definition: CfgMgr.py:33
python.CfgMgr.ModuleFacade
Definition: CfgMgr.py:20
python.CfgMgr.ModuleFacade.__init__
def __init__(self, module)
Definition: CfgMgr.py:24