CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Udayraj123

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Udayraj123/OMRChecker
Path: blob/master/main.py
Views: 205
1
"""
2
3
OMRChecker
4
5
Author: Udayraj Deshmukh
6
Github: https://github.com/Udayraj123
7
8
"""
9
10
import argparse
11
import sys
12
from pathlib import Path
13
14
from src.entry import entry_point
15
from src.logger import logger
16
17
18
def parse_args():
19
# construct the argument parse and parse the arguments
20
argparser = argparse.ArgumentParser()
21
22
argparser.add_argument(
23
"-i",
24
"--inputDir",
25
default=["inputs"],
26
# https://docs.python.org/3/library/argparse.html#nargs
27
nargs="*",
28
required=False,
29
type=str,
30
dest="input_paths",
31
help="Specify an input directory.",
32
)
33
34
argparser.add_argument(
35
"-d",
36
"--debug",
37
required=False,
38
dest="debug",
39
action="store_false",
40
help="Enables debugging mode for showing detailed errors",
41
)
42
43
argparser.add_argument(
44
"-o",
45
"--outputDir",
46
default="outputs",
47
required=False,
48
dest="output_dir",
49
help="Specify an output directory.",
50
)
51
52
argparser.add_argument(
53
"-a",
54
"--autoAlign",
55
required=False,
56
dest="autoAlign",
57
action="store_true",
58
help="(experimental) Enables automatic template alignment - \
59
use if the scans show slight misalignments.",
60
)
61
62
argparser.add_argument(
63
"-l",
64
"--setLayout",
65
required=False,
66
dest="setLayout",
67
action="store_true",
68
help="Set up OMR template layout - modify your json file and \
69
run again until the template is set.",
70
)
71
72
(
73
args,
74
unknown,
75
) = argparser.parse_known_args()
76
77
args = vars(args)
78
79
if len(unknown) > 0:
80
logger.warning(f"\nError: Unknown arguments: {unknown}", unknown)
81
argparser.print_help()
82
exit(11)
83
return args
84
85
86
def entry_point_for_args(args):
87
if args["debug"] is True:
88
# Disable tracebacks
89
sys.tracebacklimit = 0
90
for root in args["input_paths"]:
91
entry_point(
92
Path(root),
93
args,
94
)
95
96
97
if __name__ == "__main__":
98
args = parse_args()
99
entry_point_for_args(args)
100
101