This repository has been archived by the owner on Jan 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (51 loc) · 2.14 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
import sys
from loguru import logger
import os
from dhp_kma.core import KmaScoreCore
from dhp_kma.export_engine.csv_engine import CsvEngine
from dhp_kma.export_engine.json_engine import csv_to_json
from dhp_kma.export_engine.sql_engine import *
from dhp_kma.utils.command_line import create_command_line
from dhp_kma.utils.sanity_check import sanity_check
def dump_opt():
PATH = os.path.abspath(args.path)
log_level = args.debug
logger.remove()
if log_level is True:
logger.add(sys.stderr, level="DEBUG")
else:
logger.add(sys.stderr, level="INFO")
sanity_check()
if args.output_path:
OUTPUT_FOLDER_PATH = args.output_path
else:
OUTPUT_FOLDER_PATH = os.path.join(os.path.abspath("."), "output")
obj = os.scandir(PATH)
file_list = []
for entry in obj:
if entry.is_file() and entry.name.endswith(".pdf"):
file_list.append(entry)
logger.info("Found {file} files!", file=len(file_list))
export_engine = CsvEngine(folder_path=OUTPUT_FOLDER_PATH)
for file_name in file_list:
handler = KmaScoreCore(os.path.abspath(os.path.join(PATH, file_name)))
subject_dict, file_score_data = handler.run()
export_engine.run_score(file_score_data)
export_engine.run_subject(subject_dict)
export_engine.run_student(file_score_data)
export_engine.close_file()
if __name__ == "__main__":
args, parser = create_command_line()
if args.type is None:
parser.print_help()
if args.type == "dump":
dump_opt()
elif args.type == "tool":
if args.tool_type == "c2j" or args.tool_type == "csv2json":
csv_to_json(args.input_path, args.output_path)
elif args.tool_type == "sqlGenerateScore" or args.tool_type == "sqlgensco":
generate_sql_score(args.input_path, args.output_path)
elif args.tool_type == "sqlGenerateStudent" or args.tool_type == "sqlgenstu":
generate_sql_student(args.input_path, args.output_path)
elif args.tool_type == "sqlGenerateSubject" or args.tool_type == "sqlgensub":
generate_sql_subject(args.input_path, args.output_path)