diff --git a/src/staticfg/examples/build_cfg.py b/src/staticfg/examples/build_cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..6f2fc39166dc2a96d81feaa76d2c30ef2fca24e2 --- /dev/null +++ b/src/staticfg/examples/build_cfg.py @@ -0,0 +1,16 @@ +#!usr/bin/python3 + +import argparse +from staticfg import CFGBuilder + +parser = argparse.ArgumentParser(description='Generate the control flow graph\ + of a Python program') +parser.add_argument('input_file', help='Path to a file containing a Python\ + program for which the CFG must be generated') +parser.add_argument('output_file', help='Path to a file where the produced\ + visualisation of the CFG must be saved') + +args = parser.parse_args() +cfg_name = args.input_file.split('/')[-1] +cfg = CFGBuilder().build_from_file(cfg_name, args.input_file) +cfg.build_visual(args.output_file, format='png', calls=True)