-
Notifications
You must be signed in to change notification settings - Fork 6
/
joern_plot
executable file
·36 lines (27 loc) · 1.05 KB
/
joern_plot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python2
import argparse
import sourceutils.plotting.plotAST as plotASTMain
import sourceutils.plotting.plotCFG as plotCFGMain
import pickle
class CLI():
def __init__(self):
self.initializeOptParser()
self.parseCommandLine()
def initializeOptParser(self):
self.argParser = argparse.ArgumentParser(description = "Plots ASTs and CFGs generated by lain_parse or lain_filter.")
self.argParser.add_argument("graphFilename", help="Filename containing the pickl'd AST or CFG to plot.")
def parseCommandLine(self):
self.args = self.argParser.parse_args()
def determinePlotterByFilename(self, graphFilename):
f = pickle.load(file(graphFilename))
try:
a = f.nodes #@UnusedVariable
return plotCFGMain.main
except:
return plotASTMain.main
def main():
cli = CLI()
plotter = cli.determinePlotterByFilename(cli.args.graphFilename)
plotter(cli.args.graphFilename)
if __name__ == '__main__':
main()