-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·85 lines (65 loc) · 2.6 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /usr/bin/env python3
import argparse
import datetime
def valid_date(s):
try:
return datetime.datetime.strptime(s, "%Y-%m-%d")
except ValueError:
msg = "Not a valid date: '{0}'.".format(s)
raise argparse.ArgumentTypeError(msg)
def main(args):
""" Main entry point of the app """
if(args.download):
import scripts.download_sequences
scripts.download_sequences.generate_csv()
print('data updated')
if(args.plot):
import scripts.plots
df = scripts.plots.load_data()
df = scripts.plots.restrict_dates(df, args.start_date, args.end_date)
scripts.plots.generate_plots(df, args.output_dir)
print('plots generated')
if(args.table):
import scripts.plots
import scripts.tables
df = scripts.plots.load_data()
df = scripts.plots.restrict_dates(df, args.start_date, args.end_date)
scripts.tables.generate_tables(df, args.output_dir)
print('tables generated')
if(args.map):
import scripts.plots
import scripts.pie
df = scripts.plots.load_data()
df = scripts.plots.restrict_dates(df, args.start_date, args.end_date)
scripts.pie.generate_variant_map(df, args.output_dir)
print('map generated')
if(not any([args.download, args.plot, args.table, args.map])):
parser.print_help()
if __name__ == "__main__":
""" This is executed when run from the command line """
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--download",
action="store_true", help="download data, if unset, use stored data")
parser.add_argument("-p", "--plot",
action="store_true", help="create plots")
parser.add_argument("-t", "--table",
action="store_true", help="create tables")
parser.add_argument("-m", "--map",
action="store_true", help="create map")
parser.add_argument("-s",
"--start-date",
help="start date - format YYYY-MM-DD",
required=False,
type=valid_date)
parser.add_argument("-e",
"--end-date",
help="end date - format YYYY-MM-DD",
required=False,
type=valid_date)
parser.add_argument("-o",
"--output-dir",
help="output sub-directory",
required=False,
default='default')
args = parser.parse_args()
main(args)