From 965f20d8ee08b9b917ccfac59e5346eaf8c7f077 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 11 Sep 2017 20:50:35 +0800 Subject: [PATCH] doc/scripts/gen_state_diagram.py: port to py3 Signed-off-by: Kefu Chai --- doc/scripts/gen_state_diagram.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/scripts/gen_state_diagram.py b/doc/scripts/gen_state_diagram.py index f8414368c1c34..8363d9898f1b1 100755 --- a/doc/scripts/gen_state_diagram.py +++ b/doc/scripts/gen_state_diagram.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function + import re import sys @@ -148,16 +150,16 @@ class StateMachineRenderer(object): for state in self.machines.keys(): if state not in self.states.keys(): top_level.append(state) - print >> sys.stderr, "Top Level States: ", str(top_level) - print """digraph G {""" - print '\tsize="7,7"' - print """\tcompound=true;""" + print('Top Level States: ', top_level, file=sys.stderr) + print('digraph G {') + print('\tsize="7,7"') + print('\tcompound=true;') for i in self.emit_state(top_level[0]): - print '\t' + i + print('\t' + i) for i in self.edges.keys(): for j in self.emit_event(i): - print j - print """}""" + print(j) + print('}') def emit_state(self, state): if state in self.state_contents.keys(): @@ -200,7 +202,7 @@ class StateMachineRenderer(object): yield("%s -> %s %s;" % (fro, to, append(appendix))) -INPUT_GENERATOR = do_filter(sys.stdin.xreadlines()) +INPUT_GENERATOR = do_filter(line for line in sys.stdin) RENDERER = StateMachineRenderer() RENDERER.read_input(INPUT_GENERATOR) RENDERER.emit_dot() -- 2.39.5