| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# Configurable Namespace Reference

## Classes
class | Error
class | PropertyReference
| Allow references to options as in old style. More...
class | Configurable
class | DummyDescriptor
| if isinstance(v,Configurable) and not v.isPublic(): rep += v.__str__( indent + 1 ) + os.linesep elif isinstance(v,GaudiHandleArray): for vi in v: if isinstance(vi,Configurable) and not vi.isPublic(): rep += vi.__str__( indent + 1 ) + os.linesep More...
class | ConfigurableGeneric
class | ConfigurableAlgorithm
class | ConfigurableService
class | ConfigurableAlgTool
class | ConfigurableAuditor
class | ConfigurableUser
## Functions
def | expandvars
def | appendPostConfigAction
def | removePostConfigAction
def | applyConfigurableUsers
def | getNeededConfigurables
def | purge
## Variables
list | __all__
tuple | log = logging.getLogger( 'Configurable' )
list | postConfigActions = []
| _appliedConfigurableUsers_ = False

## Function Documentation

def Configurable::appendPostConfigAction | ( |  | function | ) |

    Add a new callable ('function') to the list of post-configuration actions.
    If the callable is already in the list, it is moved to the end of the list.
    The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.

Definition at line 1309 of file Configurable.py.

    01309                                     :
    01310     """
    01311     Add a new callable ('function') to the list of post-configuration actions.
    01312     If the callable is already in the list, it is moved to the end of the list.
    01313     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
    01314     """
    01315     try:
    01316         postConfigActions.remove(function)
    01317     except:
    01318         pass
    01319     postConfigActions.append(function)
    def removePostConfigAction(function):

def Configurable::applyConfigurableUsers | ( |  | ) |

    Call the apply method of all the ConfigurableUser instances respecting the
    dependencies. First the C.U.s that are not used by anybody, then the used
    ones, when they are not used anymore.

Definition at line 1328 of file Configurable.py.

    01328                             :
    01329     """
    01330     Call the apply method of all the ConfigurableUser instances respecting the
    01331     dependencies. First the C.U.s that are not used by anybody, then the used
    01332     ones, when they are not used anymore.
    01333     """
    01334     # Avoid double calls
    01335     global _appliedConfigurableUsers_, postConfigActions
    01336     if _appliedConfigurableUsers_:
    01337         return
    01338     _appliedConfigurableUsers_ = True
    01339
    01340     confUsers = [ c
    01341                   for c in Configurable.allConfigurables.values()
    01342                   if hasattr(c,"__apply_configuration__") ]
    01343     applied = True # needed to detect dependency loops
    01344     while applied and confUsers:
    01345         newConfUsers = [] # list of conf users that cannot be applied yet
    01346         applied = False
    01347         for c in confUsers:
    01348             if hasattr(c,"__users__") and c.__users__:
    01349                 newConfUsers.append(c) # cannot use this one yet
    01350             else: # it does not have users or the list is empty
    01351                 applied = True
    01352                 # the ConfigurableUser is enabled if it doesn't have an _enabled
    01353                 # property or its value is True
    01354                 enabled = (not hasattr(c, "_enabled")) or c._enabled
    01355                 if enabled:
    01356                     log.info("applying configuration of %s", c.name())
    01357                     c.__apply_configuration__()
    01358                     log.info(c)
    01359                 else:
    01360                     log.info("skipping configuration of %s", c.name())
    01361                 if hasattr(c, "__detach_used__"):
    01362                     # tells the used configurables that they are not needed anymore
    01363                     c.__detach_used__()
    01364         confUsers = newConfUsers # list of C.U.s still to go
    01365     if confUsers:
    01366         # this means that some C.U.s could not be applied because of a dependency loop
    01367         raise Error("Detected loop in the ConfigurableUser "
    01368                     " dependencies: %r" % [ c.name()
    01369                                             for c in confUsers ])
    01370     # Call post-config actions
    01371     for action in postConfigActions:
    01372         action()
    01373
    def getNeededConfigurables():

def Configurable::expandvars | ( |  | data | ) |

    Expand environment variables "data".
    Data can be string, list, tuple and dictionary. For collection, all the
    contained strings will be manipulated (recursively).

Definition at line 27 of file Configurable.py.

    00027                     :
    00028     """
    00029     Expand environment variables "data".
    00030     Data can be string, list, tuple and dictionary. For collection, all the
    00031     contained strings will be manipulated (recursively).
    00032     """
    00033     import os.path
    00034     typ = type(data)
    00035     if typ is str:
    00036         return os.path.expandvars(data)
    00037     elif typ in [list, tuple]:
    00038         collect = []
    00039         for i in data:
    00040             collect.append(expandvars(i))
    00041         return typ(collect)
    00042     elif typ is dict:
    00043         collect = {}
    00044         for k in data:
    00045             collect[expandvars(k)] = expandvars(data[k])
    00046         return collect
    00047     return data
    00048
    class Error(RuntimeError):

def Configurable::getNeededConfigurables | ( |  | ) |

    Function to select all and only the configurables that have to be used in
    GaudiPython.AppMgr constructor.
    This is needed because in Athena the implementation have to be different (the
    configuration is used in a different moment).

Definition at line 1374 of file Configurable.py.

    01374                             :
    01375     """
    01376     Function to select all and only the configurables that have to be used in
    01377     GaudiPython.AppMgr constructor.
    01378     This is needed because in Athena the implementation have to be different (the
    01379     configuration is used in a different moment).
    01380     """
    01381     return [ k
    01382              for k, v in Configurable.allConfigurables.items()
    01383              if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances
    01384
    def purge():

def Configurable::purge | ( |  | ) |

    Clean up all configurations and configurables.

Definition at line 1385 of file Configurable.py.

    01385            :
    01386     """
    01387     Clean up all configurations and configurables.
    01388     """
    01389     for c in Configurable.allConfigurables.values():
    01390         c.__class__.configurables.clear()
    01391     Configurable.allConfigurables.clear()
    01392     # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
    01393     #        migrated to the correct class when this is known.
    01394     ConfigurableGeneric.configurables.clear()
    01395     from ProcessJobOptions import _included_files
    01396     import os.path, sys
    01397     for file in _included_files:
    01398         dirname, basname = os.path.split(file)
    01399         basname, ext = os.path.splitext(basname)
    01400         if basname in sys.modules:
    01401             del sys.modules[basname]
    01402     _included_files.clear()
        _included_files.clear()

def Configurable::removePostConfigAction | ( |  | function | ) |

    Remove a collable from the list of post-config actions.
    The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.

Definition at line 1320 of file Configurable.py.

    01320                                     :
    01321     """
    01322     Remove a collable from the list of post-config actions.
    01323     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
    01324     """
    01325     postConfigActions.remove(function)
    01326
    _appliedConfigurableUsers_ = False

## Variable Documentation

list Configurable::__all__

Initial value:

    [ 'Configurable',
                'ConfigurableAlgorithm',
                'ConfigurableAlgTool',
                'ConfigurableAuditor',
                'ConfigurableService',
                'ConfigurableUser',
                'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL',
                'appendPostConfigAction', 'removePostConfigAction' ]

Definition at line 14 of file Configurable.py.

Configurable::_appliedConfigurableUsers_ = False

Definition at line 1327 of file Configurable.py.

tuple Configurable::log = logging.getLogger( 'Configurable' )

Definition at line 25 of file Configurable.py.

list Configurable::postConfigActions = []

Definition at line 1308 of file Configurable.py.