actions

Actions module.

class spicerack.actions.Actions(name: Hashable)[source]

Class to keep track and log a set of actions performed and their result with a nice string representation.

Initialize the instance.

When converted to string returns a nicely formatted representation of the instance and all its actions.

It exposes the following properties:

  • name: the name passed to the instance at instantiation time.

  • has_warnings: a bool that is True when at least one warning action was registered, False otherwise.

  • has_failures: a bool that is True when at least one failed action was registered, False otherwise.

Parameters

name (typing.Hashable) -- the name of the set of actions to be registered.

failure(message: str)None[source]

Register a failed action.

Parameters

message (str) -- the action description.

property status

Return the current status of the actions based on the worst result recorded.

Returns

the short string representation of the status, one of: PASS, WARN, FAIL.

Return type

str

success(message: str)None[source]

Register a successful action.

Parameters

message (str) -- the action description.

warning(message: str)None[source]

Register an action that require some attention.

Parameters

message (str) -- the action description.

class spicerack.actions.ActionsDict[source]

Custom dictionary with defaultdict capabilities for the spicerack.actions.Action class.

Automatically instantiate and returns a new instance of the spicerack.actions.Actions class for every missing key like a collections.defaultdict.

When accessing a missing key, the key itself is passed to the new spicerack.actions.Actions instance as name.

When converted to string returns a nicely formatted representation of the instance and all its items.