-
-
Notifications
You must be signed in to change notification settings - Fork 329
/
main.py
99 lines (80 loc) · 2.1 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
OMRChecker
Author: Udayraj Deshmukh
Github: https://github.com/Udayraj123
"""
import argparse
import sys
from pathlib import Path
from src.entry import entry_point
from src.logger import logger
def parse_args():
# construct the argument parse and parse the arguments
argparser = argparse.ArgumentParser()
argparser.add_argument(
"-i",
"--inputDir",
default=["inputs"],
# https://docs.python.org/3/library/argparse.html#nargs
nargs="*",
required=False,
type=str,
dest="input_paths",
help="Specify an input directory.",
)
argparser.add_argument(
"-d",
"--debug",
required=False,
dest="debug",
action="store_false",
help="Enables debugging mode for showing detailed errors",
)
argparser.add_argument(
"-o",
"--outputDir",
default="outputs",
required=False,
dest="output_dir",
help="Specify an output directory.",
)
argparser.add_argument(
"-a",
"--autoAlign",
required=False,
dest="autoAlign",
action="store_true",
help="(experimental) Enables automatic template alignment - \
use if the scans show slight misalignments.",
)
argparser.add_argument(
"-l",
"--setLayout",
required=False,
dest="setLayout",
action="store_true",
help="Set up OMR template layout - modify your json file and \
run again until the template is set.",
)
(
args,
unknown,
) = argparser.parse_known_args()
args = vars(args)
if len(unknown) > 0:
logger.warning(f"\nError: Unknown arguments: {unknown}", unknown)
argparser.print_help()
exit(11)
return args
def entry_point_for_args(args):
if args["debug"] is True:
# Disable tracebacks
sys.tracebacklimit = 0
for root in args["input_paths"]:
entry_point(
Path(root),
args,
)
if __name__ == "__main__":
args = parse_args()
entry_point_for_args(args)