Package CedarBackup2 :: Module cli :: Class _ActionSet
[show private | hide private]
[frames | no frames]

Type _ActionSet

object --+
         |
        _ActionSet


Class representing a set of actions to be executed.

This class does three different things. First, it ensures that the actions specified on the command-line are sensible. The command-line can only list either standard actions or extended actions specified in configuration. Also, certain actions (in NONCOMBINE_ACTIONS) cannot be combined with other actions.

Second, it enforces an execution order on the specified actions. Any time actions are combined on the command line (either standard actions or extended actions), we must make sure they get executed in a sensible order.

Third, it ensures that any pre-action or post-action hooks are scheduled and executed appropriately. Hooks are configured by building a dictionary mapping between hook action name and command. Pre-action are executed immediately before their associated action, and post-action hooks are executed immediately after their associated action.
Method Summary
  __init__(self, actions, extensions, hooks)
Constructor for the _ActionSet class.
  executeActions(self, configPath, options, config)
Executes all actions and extended actions, in the proper order.
  _buildActionSet(actions, extensionDict, preHookDict, postHookDict)
Build set of actions to be executed. (Static method)
  _buildExtensionDict(extensions)
Builds dictionary mapping extension name to extension. (Static method)
  _buildHookDicts(hooks)
Build internal dictionaries mapping action name to hook. (Static method)
  _deriveHooks(action, preHookDict, postHookDict)
Derive pre- and post-action hooks, if any, associated with named action. (Static method)
  _validateActions(actions, extensionNames)
Validate that the set of specified actions is sensible. (Static method)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Method Details

__init__(self, actions, extensions, hooks)
(Constructor)

Constructor for the _ActionSet class.

The end-result is that we first validate the requested actions, and then fill in the preHookDict, postHookDict and actionSet instance variables for later use.
Parameters:
actions - Names of actions specified on the command-line.
extensions - List of extended actions (i.e. config.extensions.actions)
hooks - List of pre- and post-action hooks (i.e. config.options.hooks)
Raises:
ValueError - If one of the specified actions is invalid.
Overrides:
__builtin__.object.__init__

executeActions(self, configPath, options, config)

Executes all actions and extended actions, in the proper order.

The built-in actions will generally use the options and config values. We also pass in the config path so that extensions modules can re-parse configuration if they want to, to add in extra information.
Parameters:
configPath - Path to configuration file on disk.
options - Command-line options to be passed to action functions.
config - Parsed configuration to be passed to action functions.
Raises:
Exception - If there is a problem executing the actions.

Static Method Details

_buildActionSet(actions, extensionDict, preHookDict, postHookDict)

Build set of actions to be executed.

The set of actions is built in the proper order, so executeActions spin through the set without thinking about it. Since we've already validated that the set of actions is sensible, we don't take any precautions here to make sure things are combined properly. If the action is listed, it will be "scheduled" for implementation.

Every item in the action set is an _ActionItem.
Parameters:
actions - Names of actions specified on the command-line.
extensionDict - Dictionary mapping extension name to ExtendedAction object.
preHookDict - Dictionary mapping action name to pre-action hook ActionSet object.
postHookDict - Dictionary mapping action name to post-action hook ActionSet object.
Returns:
Set of action items in proper order.

_buildExtensionDict(extensions)

Builds dictionary mapping extension name to extension.
Returns:
Dictionary mapping extension name to extension.

_buildHookDicts(hooks)

Build internal dictionaries mapping action name to hook.
Parameters:
hooks - List of pre- and post-action hooks (i.e. config.options.hooks)

_deriveHooks(action, preHookDict, postHookDict)

Derive pre- and post-action hooks, if any, associated with named action.
Parameters:
action - Name of action to look up
preHookDict - Dictionary mapping pre-action hooks to action name
postHookDict - Dictionary mapping post-action hooks to action name @return Tuple (preHook, postHook) per mapping, with None values if there is no hook.

_validateActions(actions, extensionNames)

Validate that the set of specified actions is sensible.

Any specified action must either be a standard action or must be among the extended actions defined in configuration. The actions from within NONCOMBINE_ACTIONS may not be combined with other actions.
Parameters:
actions - Names of actions specified on the command-line.
extensionNames - Names of extensions specified in configuration.
Raises:
ValueError - If one or more configured actions are not valid.

Generated by Epydoc 2.1 on Mon Sep 4 13:49:34 2006 http://epydoc.sf.net