-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (54 loc) · 2.21 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
from questions import QuestionMatcher
from DOCText import DocxToTextConverter
from screenshot import ScreenshotTaker
from coderunner import CProgramCompiler
from PDFGen import PDFGenerator, PDFMerger, ContentReader
from ui import PathSelector
import os
from OSchecker import OSChecker
from Folders import FolderCreator
folder_creator = FolderCreator()
folder_creator.create_folders()
os_checker = OSChecker()
os_name = os_checker.check_os()
path_selector = PathSelector()
docx_path, c_programs_path, screenshot_path = path_selector.get_paths()
ques_text = DocxToTextConverter(docx_path)
doc_text = ques_text.read_text_from_docx()
text_file_directory = "data"
text_file_path = text_file_directory+"/Questions.txt"
text_file = ques_text.create_text_file(text_file_path=text_file_path)
ques = QuestionMatcher(text_file_path, c_programs_path)
answered_questions = ques.matched_questions()
program_paths = ques.programs_paths()
executables_directory = "executables"
for i in range(0, len(program_paths)):
print(f"\n------------------Question {i+1}------------------\n"
f"{answered_questions[i]}\n"
f"------------------Answer------------------\n")
compiler = CProgramCompiler(program_path=f"{program_paths[i]}",
executables_directory=executables_directory,
os=os_name)
compiler.compile_and_run()
current_program_name = ques.programs_names()[i]
screenshot_taker = ScreenshotTaker(directory_path=screenshot_path,
program_name=f"{current_program_name}")
screenshot_taker.current_screenshots()
screenshot_taker.take_screenshot()
screenshot_taker.moving_screenshot()
for i in range(0, len(program_paths)):
current_program_name = ques.programs_names()[i]
pdf_generator = PDFGenerator(
file_name=f"{current_program_name}",
content_path=f"{program_paths[i]}",
text = f"{answered_questions[i]}\n\n",
content_reader=ContentReader,
image_path=f"temp/{current_program_name}.jpg"
)
pdf_generator.create_pdf()
pdf_files_path = "pdf_files"
pdf_merger = PDFMerger(
input_folder=pdf_files_path,
output_file="Assignment.pdf"
)
pdf_merger.merge_pdfs()