-
Notifications
You must be signed in to change notification settings - Fork 9
/
parser.py
30 lines (22 loc) · 857 Bytes
/
parser.py
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
import argparse
from tsplib_parser.tsp_file_parser import TSPParser
def parse_boolean(value: str) -> bool:
value = value.lower()
if value in ["true", "yes", "y", "1", "t"]:
return True
elif value in ["false", "no", "n", "0", "f"]:
return False
return False
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--file", help="tsp file to parse.", type=str)
parser.add_argument("--plot", help="plot the file.", default=False, type=parse_boolean)
args = parser.parse_args()
file_name: str = args.file
should_plot: bool = args.plot
if file_name is not None:
TSPParser(filename=file_name, plot_tsp=should_plot)
else:
file_name = "ulysses16.tsp"
TSPParser(filename=file_name, plot_tsp=should_plot)
# d57b652c-7f1b-4713-9ae1-4cac5f06874b