def jena_graph(java_file, args):
'''
Starts Main.java in the same folder and converts it into a query tree, then into a nested list
'''
graph = ''
#Makes the call to start Main.java - gets output of file via System.out.println(string)
cmd = ["java", "-cp", "/Users/david/libs/jena/lib/*:.", java_file, args]
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
for line in stdout:
graph += line
try:
res_graph = pp.nestedExpr(opener='(', closer=')').parseString(graph)
res_graph = res_graph.asList()
except:
print "pyparse err", graph, args
res_graph = -1
return res_graph
评论列表
文章目录