ATLAS Offline Software
Loading...
Searching...
No Matches
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__ = """
10A module facade to the repository of automatically generated configurables.
11Once 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
17import sys
18import types
19
20class 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
39sys.modules[ __name__ ] = ModuleFacade( sys.modules[ __name__ ] )
40del ModuleFacade
__init__(self, module)
Definition CfgMgr.py:24