]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
doc/script/gen_state_diagram: only run if called as a script
authorKefu Chai <kchai@redhat.com>
Thu, 19 Nov 2020 05:37:00 +0000 (13:37 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 19 Nov 2020 09:00:29 +0000 (17:00 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
doc/scripts/gen_state_diagram.py

index 868eaa287d3b41183db9f38f07b76bfb71079c9f..2054bfb1f09d5400437ce0b576dae47542d58eee 100755 (executable)
@@ -235,7 +235,8 @@ class StateMachineRenderer(object):
             yield("%s -> %s %s;" % (fro, to, append(appendix)))
 
 
-INPUT_GENERATOR = do_filter(line for line in sys.stdin)
-RENDERER = StateMachineRenderer()
-RENDERER.read_input(INPUT_GENERATOR)
-RENDERER.emit_dot()
+if __name__ == '__main__':
+    INPUT_GENERATOR = do_filter(line for line in sys.stdin)
+    RENDERER = StateMachineRenderer()
+    RENDERER.read_input(INPUT_GENERATOR)
+    RENDERER.emit_dot()