| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

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