forked from Trinkle23897/learn2018-autodown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
learn-stdio.py
executable file
·37 lines (33 loc) · 1.07 KB
/
learn-stdio.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
#!/usr/bin/env python3
import argparse
from learn import main
def get(help, choices=None, default=None):
while True:
i = input(help)
if i:
if choices and i not in choices:
pass
else:
if default == []:
i = i.split()
return i
else:
return default
def get_args():
parser = argparse.ArgumentParser()
args = parser.parse_args()
print('按回车选择默认选项 ...')
args.all = get('同步所有学期的所有课程 [y/N]:', choices=['Y', 'N', 'y', 'n'], default=None)
if args.all in ['n', 'N']:
args.all = None
args.clear = get('清空相同文件 [y/N]:', choices=['Y', 'N', 'y', 'n'], default=None)
if args.clear in ['n', 'N']:
args.clear = None
args.semester = get('学期:', default=[])
args.course = get('指定课程:', default=[])
args.ignore = get('忽略课程:', default=[])
args._pass = '.pass'
args.cookie = ''
return args
if __name__ == '__main__':
main(get_args())