| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

__init__.py
Go to the documentation of this file.
1 import os
2 import sys
3
4 __configurables_module_fullname__ = __name__ + '.Configurables'
5 __ignore_missing_configurables__ = False
6
7 # Small class that allows to access all the configurables as attributes of the
8 # instance.
9 # Used as module to allow code like
10 # @code
11 # from Gaudi.Configuration import Configurables
12 # Configurables.MyConf()
13 # @endcode
14
15
16 class _ConfigurablesModule(object):
17 # Initializes the instance
18 def __init__(self):
19 # If set to true, does not raise an AttributeError if the configurable is not found.
20 self.ignoreMissingConfigurables = False
21 self.__name__ = __configurables_module_fullname__
22
23 def __getattr__(self, name):
24 # trigger the load of the configurables database
25 from Gaudi.Configuration import confDbGetConfigurable, cfgDb
26 from Gaudi.CommonGaudiConfigurables import aliases
27 # return value
28 retval = None
29 # handle the special cases (needed for modules): __all__, __path__
30 if name == "__all__":
31 retval = cfgDb.keys()
32 elif name == "__path__":
33 raise AttributeError("'module' object has no attribute '__path__'")
34 elif name in cfgDb.keys(): # ignore private names
35 retval = confDbGetConfigurable(name)
36 elif name in aliases: # special case of aliases
37 retval = aliases[name]
38 elif self.ignoreMissingConfigurables:
39 import logging
40 logging.getLogger(__configurables_module_fullname__).warning(
41 'Configurable class %s not in database', name)
42 else:
43 # We raise an AttributeError exception if the configurable could not be found
44 # to respect the Python semantic.
45 raise AttributeError("module '%s' does not have attribute '%s'" % (
46 __configurables_module_fullname__, name))
47 return retval
48
49
50 # install the facade module instance as a module
51 Configurables = _ConfigurablesModule()
52 sys.modules[__configurables_module_fullname__] = Configurables
Gaudi._ConfigurablesModule.__name__
__name__
Definition: __init__.py:21
Gaudi._ConfigurablesModule
Definition: __init__.py:16
Gaudi._ConfigurablesModule.__getattr__
def __getattr__(self, name)
Definition: __init__.py:23
Gaudi.Configuration
Definition: Configuration.py:1
Gaudi.CommonGaudiConfigurables
Definition: CommonGaudiConfigurables.py:1
Gaudi._ConfigurablesModule.__init__
def __init__(self)
Definition: __init__.py:18
Gaudi._ConfigurablesModule.ignoreMissingConfigurables
ignoreMissingConfigurables
Definition: __init__.py:20