We run on Python 3 only, time to remove six dependency
Also fix l-c for new pip-resolver and move pep8 deps
in tox.ini to avoid conflicts.
And since we're here, update pre-commit config to support correct
hacking version.
Change-Id: Ibbe733c4be37d1a9dd9149d491591ef2e50dad6a
The usage of 'default_start_state' via the machine constructor is
deprecated usage of the 'default_start_state' property setter is
recommended. And there is no usage of default_start_state as
constructor argument in other projects [1]. It's safe to remove
it now.
[1] http://codesearch.openstack.org/?q=default_start_state&i=nope&files=&repos=
Change-Id: I454d453d513ae670ddd664d1d8b20ecf8d1202dd
The following files added utf-8 encoding but never used. So we can
remove them at all.
automaton/_utils.py
automaton/converters/pydot.py
automaton/exceptions.py
automaton/machines.py
automaton/runners.py
automaton/tests/test_fsm.py
Change-Id: I6b3b4f3b0b53cc4223cdea02e3cda8cd548a4115
1.As mentioned in [1], we should avoid using
six.iteritems to achieve iterators. We can use
dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more
readable. 2.In py2, the performance about list
should be negligible, see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Change-Id: Id4355f3f96c830e3116ef6f6e0a17d2ed0dcd1f4
Without explicitly mentioning that it should have its docs
generated sphinx won't generate docs for it, so ensure that
we list __iter__ and __contains__ so that it does get
generated docs.
Also fixes 'default_start_state' docs which were not showing
up since they were on the setter method vs the getter method.
Change-Id: I83d02a3604678d16b16f6da5384ff10543af850f
Instead of always by default overwriting an existing
transition from a state to another state on a given event
make it possible to avoid that overwriting (and raise
a duplication exception instead).
Change-Id: I7f5c1abf3b8737b71033250f7754595fbb28589a
This ensures that sphinx doc tests are ran and validated
and also runs doc8 to ensure style checks are done and adjusts
some of the current examples and code to fix found issues.
Also fixes the `get_callback_name` method which needs to check
if the __module__ is non-none (since it appears sphinx somehow
triggers it being none).
Change-Id: I54daecff219a9e9be71ff382d36fc2d5e67360cf
For hierarchical machines it seems like it would be
quite useful to allow nested machines to initialize to
states that are not just none so to enable this allow for
providing a callback that will be used to determine the
callback for all nested machines (and nested-nested
machines) so that they can be initialized to the users
desire.
Change-Id: I45a0c0e0c2a976e0df094e6c728f943766be7c7a
Certain projects use ``None`` as a state (and it is
possible for other projects to use other hashable
objects as states) so make it possible to provide
a renaming dict that can provide an alternative name
mapping.
This allows those projects to translate their states
into something useful on conversion.
Change-Id: I1debeaf0c1d7a7af58376ada50b014cf5de40746
Terminal states are by there very nature terminal and can not
have transitions to other states on any kind of event so on add
make sure we disallow those types of transitions to even be
created in the first place.
Change-Id: I70321e9482a0d053a8cb0bc89a766b5fbc82f69e
Perform a better and more uniform (calling into a single
function) job at fetching a callbacks fully qualified name.
Change-Id: Ia0693b8e06fa5bed2beabfff9c8b6023e8b58980
To make it easier for users of this library to
differentiate general exceptions from automaton
exceptions it is quite common to have a root exception
class that libraries use (and derive there exceptions
from); this adds that.
Change-Id: I140cb188f58849ac5caea97ed5a422375b549f6f
Both ironic and taskflow share this same code to convert
their state machines into a pydot graph which then gets
converted into SVG to form:
- http://docs.openstack.org/developer/taskflow/states.html
- http://docs.openstack.org/developer/ironic/dev/states.html
So instead of duplicating it, provide a useful helper function
that both (and others) can share to produce a dot/graphviz pretty
diagram from a state machine.
Change-Id: I218740910163a1ca2587d706edc55852af1c0c74
When using a state machine it is not always desired
to use the runner concept, so to ensure both concepts
are modular split runners off into there own module.
Change-Id: Iac8ce50b0a17468190f3f737663b5b094c324a55
When the initial start state is exited from some event
to a new stable state it is nice to have its 'on_exit'
callback be triggerred.
The 'on_enter' is not triggered since the initialization
of a machine to a start state is not triggered by an event
and is more along the line of 'priming' the state machine,
not triggering any events that cause a transition to occur.
Allow for the start_state (really the default start
state, since initialize can change it) to be provided
in the constructor, as well as set via a property that
will be used by default in initialize (if one is not
provided that overrides the initial state).
When a derived class is requested to copy it should
get a new instance of the derived class and not always
a instance of the state machine base class, so we should
make that happen correctly.
For the cases where it is desireable to force the machine
to start in a state that is not the constructor provided
state allow that to be possible using the initialize method.
By default it performs the existing behavior.