Skip to content
Snippets Groups Projects
Commit fc83518a authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Use argparse

Because we want to add an option.
parent 4c00cc1b
No related branches found
No related tags found
No related merge requests found
......@@ -9,14 +9,16 @@ found then the trajectories are colored in red.
"""
import graph_tool
import sys
import pygraphviz as pgv
import json
import argparse
if len(sys.argv) != 3:
sys.exit("Required arguments: input-Graph-tool-file output-Graphviz-file")
parser = argparse.ArgumentParser()
parser.add_argument("input_file", help = "Graph-tool file")
parser.add_argument("output_file", help = "Graphviz file")
args = parser.parse_args()
g_in = graph_tool.load_graph(sys.argv[1])
g_in = graph_tool.load_graph(args.input_file)
g_out = pgv.AGraph(directed = True)
for v in g_in.vertices():
......@@ -42,7 +44,7 @@ else:
e = g_out.get_edge(segment_list[i], segment_list[i + 1])
e.attr["color"] = "red"
g_out.write(sys.argv[2])
g_out.write(args.output_file)
g_out.close()
# strange failure of the script without this, except in ipython:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment