actions¶
Actions module.
-
class
spicerack.actions.
Actions
(name: Hashable)[source]¶ Bases:
object
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
: abool
that isTrue
when at least one warning action was registered,False
otherwise.has_failures
: abool
that isTrue
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.
-
success
(message: str) → None[source]¶ Register a successful action.
- Parameters
message (str) -- the action description.
-
class
spicerack.actions.
ActionsDict
[source]¶ Bases:
dict
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 acollections.defaultdict
.When accessing a missing key, the key itself is passed to the new
spicerack.actions.Actions
instance asname
.When converted to string returns a nicely formatted representation of the instance and all its items.