actions¶
Actions module.
-
class
spicerack.actions.
Actions
(name: collections.abc.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
: 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.
-
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
-
class
spicerack.actions.
ActionsDict
[source]¶ OrderedDict with defaultdict capabilities for the
spicerack.actions.Action
class.Inherits from
collections.OrderedDict
and automatically instantiate and returns a new instance of thespicerack.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.
Todo
Once the support of Python 3.5 is dropped this can be converted into a simple factory with a single
new()
method that returns an instance ofdefaultdict(Actions)
.