Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
GaudiKernel.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__
 data ------------------------------------------------------------------—
 
tuple log logging.getLogger( 'Configurable' )
 
list postConfigActions []
 
 _appliedConfigurableUsers_ False
 

Function Documentation

def GaudiKernel.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.

1310 def appendPostConfigAction(function):
1311  """
1312  Add a new callable ('function') to the list of post-configuration actions.
1313  If the callable is already in the list, it is moved to the end of the list.
1314  The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
1315  """
1316  try:
1317  postConfigActions.remove(function)
1318  except:
1319  pass
postConfigActions.append(function)
def GaudiKernel.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.

1330  """
1331  Call the apply method of all the ConfigurableUser instances respecting the
1332  dependencies. First the C.U.s that are not used by anybody, then the used
1333  ones, when they are not used anymore.
1334  """
1335  # Avoid double calls
1336  global _appliedConfigurableUsers_, postConfigActions
1337  if _appliedConfigurableUsers_:
1338  return
1339  _appliedConfigurableUsers_ = True
1340 
1341  confUsers = [ c
1342  for c in Configurable.allConfigurables.values()
1343  if hasattr(c,"__apply_configuration__") ]
1344  applied = True # needed to detect dependency loops
1345  while applied and confUsers:
1346  newConfUsers = [] # list of conf users that cannot be applied yet
1347  applied = False
1348  for c in confUsers:
1349  if hasattr(c,"__users__") and c.__users__:
1350  newConfUsers.append(c) # cannot use this one yet
1351  else: # it does not have users or the list is empty
1352  applied = True
1353  # the ConfigurableUser is enabled if it doesn't have an _enabled
1354  # property or its value is True
1355  enabled = (not hasattr(c, "_enabled")) or c._enabled
1356  if enabled:
1357  log.info("applying configuration of %s", c.name())
1358  c.__apply_configuration__()
1359  log.info(c)
1360  else:
1361  log.info("skipping configuration of %s", c.name())
1362  if hasattr(c, "__detach_used__"):
1363  # tells the used configurables that they are not needed anymore
1364  c.__detach_used__()
1365  confUsers = newConfUsers # list of C.U.s still to go
1366  if confUsers:
1367  # this means that some C.U.s could not be applied because of a dependency loop
1368  raise Error("Detected loop in the ConfigurableUser "
1369  " dependencies: %r" % [ c.name()
1370  for c in confUsers ])
1371  # ensure that all the Handles have been triggered
1372  known = set()
1373  unknown = set(Configurable.allConfigurables)
1374  while unknown:
1375  for k in unknown:
1376  if not known: # do not print during the first iteration
1377  log.debug('new configurable created automatically: %s', k)
1378  # this trigger the instantiation from handles
1379  Configurable.allConfigurables[k].properties()
1380  known.add(k)
1381  unknown -= known
1382  # Call post-config actions
1383  for action in postConfigActions:
1384  action()
def GaudiKernel.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.

27 
28 def expandvars(data):
29  """
30  Expand environment variables "data".
31  Data can be string, list, tuple and dictionary. For collection, all the
32  contained strings will be manipulated (recursively).
33  """
34  import os.path
35  typ = type(data)
36  if typ is str:
37  return os.path.expandvars(data)
38  elif typ in [list, tuple]:
39  collect = []
40  for i in data:
41  collect.append(expandvars(i))
42  return typ(collect)
43  elif typ is dict:
44  collect = {}
45  for k in data:
46  collect[expandvars(k)] = expandvars(data[k])
47  return collect
48  return data
def GaudiKernel.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 1385 of file Configurable.py.

1387  """
1388  Function to select all and only the configurables that have to be used in
1389  GaudiPython.AppMgr constructor.
1390  This is needed because in Athena the implementation have to be different (the
1391  configuration is used in a different moment).
1392  """
1393  return [ k
1394  for k, v in Configurable.allConfigurables.items()
1395  if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances
def GaudiKernel.Configurable.purge ( )
Clean up all configurations and configurables.

Definition at line 1396 of file Configurable.py.

1397 def purge():
1398  """
1399  Clean up all configurations and configurables.
1400  """
1401  for c in Configurable.allConfigurables.values():
1402  c.__class__.configurables.clear()
1403  Configurable.allConfigurables.clear()
1404  # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
1405  # migrated to the correct class when this is known.
1406  ConfigurableGeneric.configurables.clear()
1407  from ProcessJobOptions import _included_files
1408  import os.path, sys
1409  for file in _included_files:
1410  dirname, basname = os.path.split(file)
1411  basname, ext = os.path.splitext(basname)
1412  if basname in sys.modules:
1413  del sys.modules[basname]
1414  _included_files.clear()
def GaudiKernel.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.

1321 def removePostConfigAction(function):
1322  """
1323  Remove a collable from the list of post-config actions.
1324  The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
1325  """
1326  postConfigActions.remove(function)

Variable Documentation

list GaudiKernel.Configurable.__all__
Initial value:
1 [ 'Configurable',
2  'ConfigurableAlgorithm',
3  'ConfigurableAlgTool',
4  'ConfigurableAuditor',
5  'ConfigurableService',
6  'ConfigurableUser',
7  'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL',
8  'appendPostConfigAction', 'removePostConfigAction' ]

data ------------------------------------------------------------------—

Definition at line 14 of file Configurable.py.

GaudiKernel.Configurable._appliedConfigurableUsers_ False

Definition at line 1327 of file Configurable.py.

tuple GaudiKernel.Configurable.log logging.getLogger( 'Configurable' )

Definition at line 25 of file Configurable.py.

list GaudiKernel.Configurable.postConfigActions []

Definition at line 1308 of file Configurable.py.


Generated at Wed Dec 4 2013 14:33:22 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004