diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-12-05 21:23:56 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-07-14 10:21:28 -0700 |
commit | 50f710eaeec8556e7ea43e52f00528822afbcb22 (patch) | |
tree | 81bb43658153d4952c54421ccf92576d254c1ed3 /tools | |
parent | 9f846d0475b9862da6af52bd959d15a2cd8f5ab0 (diff) | |
download | taskflow-50f710eaeec8556e7ea43e52f00528822afbcb22.tar.gz |
Replace internal fsm + table with automaton library
Instead of having our own inbuilt fsm and table library
used to print the fsm states just use the newly created
and released automaton that contains the same/similar
code but as a released library that others can use and
benefit from.
Library @ http://pypi.python.org/pypi/automaton
Change-Id: I1ca40a0805e704fbb37b0106c1831a7e45c6ad68
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/state_graph.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/state_graph.py b/tools/state_graph.py index c37cd70..e7f2d13 100755 --- a/tools/state_graph.py +++ b/tools/state_graph.py @@ -29,10 +29,11 @@ sys.path.insert(0, top_dir) # $ pip install pydot2 import pydot +from automaton import machines + from taskflow.engines.action_engine import runner from taskflow.engines.worker_based import protocol from taskflow import states -from taskflow.types import fsm # This is just needed to get at the runner builder object (we will not @@ -52,7 +53,7 @@ def clean_event(name): def make_machine(start_state, transitions): - machine = fsm.FSM(start_state) + machine = machines.FiniteMachine() machine.add_state(start_state) for (start_state, end_state) in transitions: if start_state not in machine: @@ -62,6 +63,7 @@ def make_machine(start_state, transitions): # Make a fake event (not used anyway)... event = "on_%s" % (end_state) machine.add_transition(start_state, end_state, event.lower()) + machine.default_start_state = start_state return machine @@ -192,7 +194,7 @@ def main(): start = pydot.Node("__start__", shape="point", width="0.1", xlabel='start', fontcolor='green', **node_attrs) g.add_node(start) - g.add_edge(pydot.Edge(start, nodes[source.start_state], style='dotted')) + g.add_edge(pydot.Edge(start, nodes[source.default_start_state], style='dotted')) print("*" * len(graph_name)) print(graph_name) |