-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·62 lines (47 loc) · 1.48 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
#!/usr/bin/python3
import os.path
import argparse
from src.app import main as app_main
def run():
parser = argparse.ArgumentParser()
# command line arguments
parser.add_argument(
"--input-path",
help="Absolute path to input directory where .csv files reside",
# nargs="+",
required=True
)
parser.add_argument(
"--promotion-type",
default=None,
help="The type of promotion scheme",
)
parser.add_argument(
"--output-path",
help="Absolute path to output file to store results",
default="output/output.csv"
)
argvs = parser.parse_args()
if validate_path_dir(argvs, "input_path"):
arg_input_path = argvs.input_path
if validate_path_file(argvs, "output_path"):
arg_output_path = argvs.output_path
arg_promotion_type = argvs.promotion_type
if arg_promotion_type is None:
print("please input promotion type")
else:
app_main(arg_input_path, arg_promotion_type, arg_output_path)
def validate_path_dir(argvs, opt):
path_ = getattr(argvs, opt)
if not os.path.isdir(path_):
print("Directory path {} of {} does not exists".format(path_, opt))
return False
return True
def validate_path_file(argvs, opt):
path_ = getattr(argvs, opt)
if not os.path.isfile(path_):
print("File path {} of {} does not exists".format(path_, opt))
return False
return True
if __name__ == '__main__':
run()