-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_question.py
43 lines (39 loc) · 910 Bytes
/
get_question.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
import argparse
import subprocess
DEFAULT_LANGUAGE = 'python3'
def get_question(question_number, language, folder):
folder = folder or language
out = subprocess.check_output(
[
'leetcode',
'submission',
question_number,
'-x',
'-l',
language,
'-o',
folder,
],
)
return out.decode()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Download target question and approved answer.')
parser.add_argument(
'question_number',
help='Question to download.'
)
parser.add_argument(
'--language',
'-l',
default=DEFAULT_LANGUAGE,
help='Language for template.',
)
parser.add_argument(
'--folder',
'-f',
help='Target folder.',
)
args = parser.parse_args()
print(
get_question(args.question_number, args.language, args.folder)
)