Coverage for skema/program_analysis/cast_to_agraph.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1import sys 

2 

3from skema.program_analysis.CAST2FN.visitors.cast_to_agraph_visitor import ( 

4 CASTToAGraphVisitor, 

5) 

6from skema.program_analysis.CAST2FN.cast import CAST 

7 

8def main(): 

9 """cast_to_agraph.py 

10 

11 This program reads a JSON file that contains the CAST representation 

12 of a program, and generates a PDF file out of it to visualize it. 

13 

14 One command-line argument is expected, namely the name of the JSON file that 

15 contains the CAST data. 

16 """ 

17 f_name = sys.argv[1] 

18 file_contents = open(f_name).read() 

19 C = CAST([], "python") 

20 C2 = C.from_json_str(file_contents) 

21 

22 V = CASTToAGraphVisitor(C2) 

23 last_slash_idx = f_name.rfind("/") 

24 file_ending_idx = f_name.rfind(".") 

25 pdf_file_name = f"{f_name[last_slash_idx + 1 : file_ending_idx]}.pdf" 

26 V.to_pdf(pdf_file_name) 

27 

28 

29if __name__ == "__main__": 

30 main()