-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (58 loc) · 1.22 KB
/
main.py
File metadata and controls
66 lines (58 loc) · 1.22 KB
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
import sys
import argparse
import communicate
main_parser = argparse.ArgumentParser(
description = """
This is a tester for interactive problem.
You can communicate your code which is checker and code which you want to check.
"""
)
main_parser.add_argument(
"checker",
metavar = "checker_file",
type = str,
nargs = 1,
help = """
File that you want to use to check your source code.
"""
)
main_parser.add_argument(
"source",
metavar = "source_file",
type = str,
nargs = 1,
help = """
File that contains your source you want to check.
"""
)
main_parser.add_argument(
"-e",
dest = "end_characters",
metavar = "characters",
type = str,
nargs = '*',
default = [],
help = """
List of characters which will end the communication.
"""
)
main_parser.add_argument(
"-f", "--first",
dest = "source_first",
action = "store_true",
default = False,
help = """
Set source code will go first.
"""
)
def run():
arg = main_parser.parse_args()
communication = communicate.Communication(arg.checker, arg.source)
arg.end_characters.append('')
communication.communicate(arg.end_characters, arg.source_first)
if __name__ == '__main__':
try:
run()
except Exception as e:
print(f"Exit code of program: {e}")
sys.exit(1)