-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (39 loc) · 1.68 KB
/
main.py
File metadata and controls
51 lines (39 loc) · 1.68 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
import zip_postprocessor.main
from docx_optimizer import select_word_file, extract_images_from_docx, compress_images_in_docx
from upload_manager.upload_flow import process_upload_flow
from utils import clear_temp_dir, Status
from word_to_html_converter import convert
def mainAction(app=None):
try:
if app:
app.update_status(Status.PROCESSING)
# очищаем данные предыдущей методички
clear_temp_dir()
word_path = select_word_file()
app.mark_step_done("word_selected")
images_dir = extract_images_from_docx(word_path)
app.mark_step_done("images_extracted")
compressed_path = compress_images_in_docx(word_path)
app.mark_step_done("docx_compressed")
app.update_status(Status.CONVERTING)
converted_path = convert(compressed_path)
app.mark_step_done("html_converted")
app.update_status(Status.PROCESSING)
html_path, upload_zip_path, upload_folder_path = zip_postprocessor.main.run_postprocessing(
converted_path, images_dir, word_path
)
app.mark_step_done("images_renamed")
app.mark_step_done("upload_prepared")
process_upload_flow(
html_path=html_path,
assets_zip_path=upload_zip_path,
original_zip_path=converted_path,
app=app
)
app.mark_step_done("uploaded")
else:
print("App is not initialized")
except Exception as e:
print(f"🔴 Критическая ошибка: {e}")
if __name__ == '__main__':
mainAction()