исправил функцию export_opened_to_raster

This commit is contained in:
Andrey 2025-03-28 16:02:45 +03:00
parent 7904c3ba62
commit 11bbdac99a
12 changed files with 5302 additions and 5289 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -14,17 +14,17 @@ Types if import:
IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
tracking down the missing module yourself. Thanks!
missing module named pwd - imported by posixpath (delayed, conditional, optional), subprocess (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), http.server (delayed, optional), webbrowser (delayed), netrc (delayed, conditional), getpass (delayed)
missing module named grp - imported by subprocess (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional)
missing module named pwd - imported by posixpath (delayed, conditional, optional), pathlib (delayed, optional), shutil (delayed, optional), tarfile (optional), subprocess (delayed, conditional, optional), http.server (delayed, optional), webbrowser (delayed), netrc (delayed, conditional), getpass (delayed)
missing module named grp - imported by pathlib (delayed, optional), shutil (delayed, optional), tarfile (optional), subprocess (delayed, conditional, optional)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed)
missing module named fcntl - imported by subprocess (optional), kivy.input.providers.hidinput (conditional), kivy.input.providers.linuxwacom (conditional)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional)
missing module named org - imported by pickle (optional)
missing module named urllib.pathname2url - imported by urllib (conditional), kivy.core.video.video_gstplayer (conditional), kivy.core.audio.audio_gstplayer (conditional)
missing module named posix - imported by os (conditional, optional), posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional)
missing module named posix - imported by os (conditional, optional), posixpath (optional), importlib._bootstrap_external (conditional), shutil (conditional)
missing module named resource - imported by posix (top-level)
missing module named org - imported by copy (optional)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by tty (top-level), getpass (optional)
@ -57,43 +57,43 @@ missing module named typing_extensions - imported by PIL._typing (conditional, o
missing module named numpy - imported by PIL._typing (conditional, optional), kivy.core.camera.camera_android (delayed), kivy.core.camera.camera_picamera (top-level)
missing module named olefile - imported by PIL.FpxImagePlugin (top-level), PIL.MicImagePlugin (top-level)
missing module named defusedxml - imported by PIL.Image (optional)
missing module named pygame - imported by kivy.input.providers.androidjoystick (conditional), kivy.app (delayed, conditional), kivy.core.window.window_pygame (top-level), kivy.support (delayed), kivy.core.text.text_pygame (optional), kivy.core.audio.audio_pygame (conditional, optional), kivy.core.clipboard.clipboard_pygame (optional), kivy.core.image.img_pygame (optional)
missing module named android - imported by kivy.metrics (delayed, conditional), kivy.core.window (delayed, conditional), kivy.base (delayed, optional), kivy.input.providers.androidjoystick (optional), kivy.app (delayed, conditional), kivy.core.window.window_sdl2 (delayed, conditional), kivy.core.window.window_pygame (conditional, optional), kivy.support (delayed, optional), kivy.core.clipboard.clipboard_android (top-level), kivy.core.audio.audio_android (top-level)
missing module named gobject - imported by kivy.support (delayed, optional)
missing module named gi - imported by kivy.support (delayed, optional), kivy.core.clipboard.clipboard_gtk3 (top-level)
missing module named 'gi.repository' - imported by kivy.core.clipboard.clipboard_gtk3 (top-level), kivy.core.camera.camera_gi (top-level)
missing module named ffmpeg - imported by kivy.core.video.video_ffmpeg (optional)
missing module named 'pyobjus.dylib_manager' - imported by kivy.core.clipboard.clipboard_nspaste (optional), kivy.core.audio.audio_avplayer (top-level)
missing module named pyobjus - imported by kivy.core.clipboard.clipboard_nspaste (optional), kivy.core.audio.audio_avplayer (top-level)
missing module named 'ffpyplayer.tools' - imported by kivy.core.video.video_ffpyplayer (optional), kivy.core.image.img_ffpyplayer (top-level), kivy.core.audio.audio_ffpyplayer (optional)
missing module named 'ffpyplayer.player' - imported by kivy.core.video.video_ffpyplayer (optional), kivy.core.audio.audio_ffpyplayer (optional)
missing module named ffpyplayer - imported by kivy.core.video.video_ffpyplayer (optional), kivy.core.image.img_ffpyplayer (top-level), kivy.core.audio.audio_ffpyplayer (optional)
missing module named jnius - imported by kivy.metrics (delayed, conditional), kivy.app (delayed, conditional), kivy.core.camera.camera_android (top-level), kivy.core.clipboard.clipboard_android (top-level), kivy.core.audio.audio_android (top-level)
missing module named 'pygame.scrap' - imported by kivy.core.clipboard.clipboard_pygame (optional)
missing module named 'ffpyplayer.pic' - imported by kivy.core.image.img_ffpyplayer (top-level)
missing module named Leap - imported by kivy.input.providers.leapfinger (delayed)
missing module named pygame - imported by kivy.input.providers.androidjoystick (conditional), kivy.app (delayed, conditional), kivy.core.window.window_pygame (top-level), kivy.support (delayed), kivy.core.audio.audio_pygame (conditional, optional), kivy.core.clipboard.clipboard_pygame (optional), kivy.core.text.text_pygame (optional), kivy.core.image.img_pygame (optional)
missing module named android - imported by kivy.metrics (delayed, conditional), kivy.core.window (delayed, conditional), kivy.base (delayed, optional), kivy.input.providers.androidjoystick (optional), kivy.app (delayed, conditional), kivy.core.window.window_pygame (conditional, optional), kivy.support (delayed, optional), kivy.core.window.window_sdl2 (delayed, conditional), kivy.core.audio.audio_android (top-level), kivy.core.clipboard.clipboard_android (top-level)
missing module named oscpy - imported by kivy.input.providers.tuio (delayed, optional)
missing module named picamera - imported by kivy.core.camera.camera_picamera (top-level)
missing module named 'android.runnable' - imported by kivy.core.clipboard.clipboard_android (top-level)
missing module named chardet - imported by pygments.lexer (delayed, conditional, optional)
missing module named pygments.formatters.BBCodeFormatter - imported by pygments.formatters (top-level), kivy.uix.codeinput (top-level)
missing module named pygments.lexers.PrologLexer - imported by pygments.lexers (top-level), pygments.lexers.cplint (top-level)
missing module named ctags - imported by pygments.formatters.html (optional)
missing module named dbus - imported by kivy.core.clipboard.clipboard_dbusklipper (optional)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named Image - imported by kivy.core.image.img_pil (optional), docutils.parsers.rst.directives.images (optional)
missing module named roman - imported by docutils.writers.latex2e (optional), docutils.writers.manpage (optional)
missing module named 'kivy.core.text._text_pango' - imported by kivy.core.text.text_pango (top-level)
missing module named 'ffpyplayer.tools' - imported by kivy.core.audio.audio_ffpyplayer (optional), kivy.core.image.img_ffpyplayer (top-level), kivy.core.video.video_ffpyplayer (optional)
missing module named 'ffpyplayer.player' - imported by kivy.core.audio.audio_ffpyplayer (optional), kivy.core.video.video_ffpyplayer (optional)
missing module named ffpyplayer - imported by kivy.core.audio.audio_ffpyplayer (optional), kivy.core.image.img_ffpyplayer (top-level), kivy.core.video.video_ffpyplayer (optional)
missing module named cv2 - imported by kivy.core.camera.camera_android (delayed), kivy.core.camera.camera_opencv (optional)
missing module named 'opencv.highgui' - imported by kivy.core.camera.camera_opencv (optional)
missing module named opencv - imported by kivy.core.camera.camera_opencv (optional)
missing module named android_mixer - imported by kivy.core.audio.audio_pygame (conditional, optional)
missing module named 'android.mixer' - imported by kivy.core.audio.audio_pygame (conditional, optional)
missing module named picamera - imported by kivy.core.camera.camera_picamera (top-level)
missing module named 'android.runnable' - imported by kivy.core.clipboard.clipboard_android (top-level)
missing module named jnius - imported by kivy.metrics (delayed, conditional), kivy.app (delayed, conditional), kivy.core.audio.audio_android (top-level), kivy.core.camera.camera_android (top-level), kivy.core.clipboard.clipboard_android (top-level)
missing module named smb - imported by kivy.loader (delayed, conditional, optional)
missing module named 'pyobjus.dylib_manager' - imported by kivy.core.audio.audio_avplayer (top-level), kivy.core.clipboard.clipboard_nspaste (optional)
missing module named pyobjus - imported by kivy.core.audio.audio_avplayer (top-level), kivy.core.clipboard.clipboard_nspaste (optional)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named Image - imported by kivy.core.image.img_pil (optional), docutils.parsers.rst.directives.images (optional)
missing module named pygments.formatters.BBCodeFormatter - imported by pygments.formatters (top-level), kivy.uix.codeinput (top-level)
missing module named ctags - imported by pygments.formatters.html (optional)
missing module named pygments.lexers.PrologLexer - imported by pygments.lexers (top-level), pygments.lexers.cplint (top-level)
missing module named chardet - imported by pygments.lexer (delayed, conditional, optional)
missing module named roman - imported by docutils.writers.latex2e (optional), docutils.writers.manpage (optional)
missing module named 'ffpyplayer.pic' - imported by kivy.core.image.img_ffpyplayer (top-level)
missing module named enchant - imported by kivy.core.spelling.spelling_enchant (top-level)
missing module named AppKit - imported by kivy.core.spelling.spelling_osxappkit (top-level)
missing module named kivy.lib.vidcore_lite.egl - imported by kivy.lib.vidcore_lite (top-level), kivy.core.window.window_egl_rpi (top-level)
missing module named kivy.lib.vidcore_lite.bcm - imported by kivy.lib.vidcore_lite (top-level), kivy.core.window.window_egl_rpi (top-level)
missing module named smb - imported by kivy.loader (delayed, conditional, optional)
missing module named AppKit - imported by kivy.core.spelling.spelling_osxappkit (top-level)
missing module named 'kivy.core.text._text_pango' - imported by kivy.core.text.text_pango (top-level)
missing module named gobject - imported by kivy.support (delayed, optional)
missing module named gi - imported by kivy.support (delayed, optional), kivy.core.clipboard.clipboard_gtk3 (top-level)
missing module named 'gi.repository' - imported by kivy.core.clipboard.clipboard_gtk3 (top-level), kivy.core.camera.camera_gi (top-level)
missing module named 'pygame.scrap' - imported by kivy.core.clipboard.clipboard_pygame (optional)
missing module named android_mixer - imported by kivy.core.audio.audio_pygame (conditional, optional)
missing module named 'android.mixer' - imported by kivy.core.audio.audio_pygame (conditional, optional)
missing module named ffmpeg - imported by kivy.core.video.video_ffmpeg (optional)
missing module named dbus - imported by kivy.core.clipboard.clipboard_dbusklipper (optional)
missing module named ConfigParser - imported by kivy.config (optional)
missing module named usercustomize - imported by site (delayed, optional)
missing module named sitecustomize - imported by site (delayed, optional)

View File

@ -464,7 +464,7 @@ imported by:
<a target="code" href="" type="text/plain"><tt>'org.python'</tt></a>
<span class="moduletype">MissingModule</span> <div class="import">
imported by:
<a href="#pickle">pickle</a>
<a href="#copy">copy</a>
&#8226; <a href="#xml.sax">xml.sax</a>
</div>
@ -5684,6 +5684,7 @@ imported by:
&#8226; <a href="#docutils">docutils</a>
&#8226; <a href="#docutils.nodes">docutils.nodes</a>
&#8226; <a href="#email.feedparser">email.feedparser</a>
&#8226; <a href="#export_opened_to_raster">export_opened_to_raster</a>
&#8226; <a href="#functools">functools</a>
&#8226; <a href="#importlib.metadata">importlib.metadata</a>
&#8226; <a href="#importlib.metadata._collections">importlib.metadata._collections</a>
@ -6035,8 +6036,8 @@ imported by:
<a target="code" href="///C:/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0/Lib/copy.py" type="text/plain"><tt>copy</tt></a>
<span class="moduletype">SourceModule</span> <div class="import">
imports:
<a href="#copyreg">copyreg</a>
&#8226; <a href="#org">org</a>
<a href="#'org.python'">'org.python'</a>
&#8226; <a href="#copyreg">copyreg</a>
&#8226; <a href="#types">types</a>
&#8226; <a href="#weakref">weakref</a>
@ -12172,6 +12173,7 @@ imports:
&#8226; <a href="#PIL.Image">PIL.Image</a>
&#8226; <a href="#PIL.ImageDraw">PIL.ImageDraw</a>
&#8226; <a href="#PIL.ImageFont">PIL.ImageFont</a>
&#8226; <a href="#collections">collections</a>
&#8226; <a href="#os">os</a>
&#8226; <a href="#pythoncom">pythoncom</a>
&#8226; <a href="#win32com.client">win32com.client</a>
@ -21329,7 +21331,7 @@ imported by:
<a target="code" href="" type="text/plain"><tt>org</tt></a>
<span class="moduletype">MissingModule</span> <div class="import">
imported by:
<a href="#copy">copy</a>
<a href="#pickle">pickle</a>
</div>
@ -22135,14 +22137,14 @@ imported by:
<a target="code" href="///C:/Program%20Files/WindowsApps/PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0/Lib/pickle.py" type="text/plain"><tt>pickle</tt></a>
<span class="moduletype">SourceModule</span> <div class="import">
imports:
<a href="#'org.python'">'org.python'</a>
&#8226; <a href="#_compat_pickle">_compat_pickle</a>
<a href="#_compat_pickle">_compat_pickle</a>
&#8226; <a href="#_pickle">_pickle</a>
&#8226; <a href="#codecs">codecs</a>
&#8226; <a href="#copyreg">copyreg</a>
&#8226; <a href="#functools">functools</a>
&#8226; <a href="#io">io</a>
&#8226; <a href="#itertools">itertools</a>
&#8226; <a href="#org">org</a>
&#8226; <a href="#pprint">pprint</a>
&#8226; <a href="#re">re</a>
&#8226; <a href="#struct">struct</a>

Binary file not shown.

View File

@ -1,27 +1,28 @@
import os
import pythoncom
from win32com.client import Dispatch, gencache
import os
from PIL import Image, ImageDraw, ImageFont
from collections import defaultdict
def export_opened_to_raster():
try:
# Инициализация счетчиков
counters = {
'total_processed': 0,
'jpg_created': 0,
'dxf_created': 0,
'pdf_created': 0,
'errors': 0
}
# Списки для хранения путей к файлам
created_files = {
'jpg': [],
'dxf': [],
'pdf': None
}
"""
Функция для экспорта открытых документов КОМПАС в JPG, DXF и PDF
Возвращает строку с подробной статистикой выполнения
"""
result = []
stats = {
'total_docs': 0,
'processed_docs': 0,
'jpg_created': 0,
'dxf_created': 0,
'errors': 0,
'created_files': defaultdict(list),
'pdf_created': False,
'pdf_path': None
}
# Получаем API интерфейсов
try:
# Получаем API интерфейсов версии 5
api5_module = gencache.EnsureModule("{0422828C-F174-495E-AC5D-D31014DBBE87}", 0, 1, 0)
api5_api = api5_module.KompasObject(
Dispatch("Kompas.Application.5")._oleobj_.QueryInterface(
@ -41,141 +42,150 @@ def export_opened_to_raster():
).constants
application = module.IApplication(api)
application.Visible = True
print("=== НАЧАЛО ОБРАБОТКИ ДОКУМЕНТОВ ===")
save_param = None
images = []
# Обработка документов
application.Visible = True
first_doc_name = None
stats['total_docs'] = application.Documents.Count
result.append(f"Найдено документов: {stats['total_docs']}")
result.append("Начинаем обработку...\n")
# Собираем информацию о всех документах перед созданием PDF
docs_info = []
for i in range(application.Documents.Count):
try:
doc = application.Documents.Open(i)
counters['total_processed'] += 1
doc_type = doc.DocumentType
if doc_type not in [
if doc_type in [
k_constants.ksDocumentDrawing,
k_constants.ksDocumentFragment,
k_constants.ksDocumentSpecification,
]:
continue
doc.Active = True
doc_path = doc.Path
doc_name = "-".join(doc.Name.split(".")[:-1])
stats['processed_docs'] += 1
doc_path = doc.Path
doc_name = os.path.splitext(doc.Name)[0]
print(f"\nОбработка документа {counters['total_processed']}: {doc_name}")
doc_api5 = api5_api.ActiveDocument2D()
doc_api7 = module.IKompasDocument(doc)
doc_api5 = api5_api.ActiveDocument2D()
doc_api7 = module.IKompasDocument(doc)
if first_doc_name is None:
first_doc_name = (
doc_api7.LayoutSheets.ItemByNumber(1).Stamp.Text(2).Str
)
# Сохраняем имя первого документа для PDF
if 'first_doc_name' not in locals():
first_doc_name = doc_api7.LayoutSheets.ItemByNumber(1).Stamp.Text(2).Str
if doc_type == k_constants.ksDocumentSpecification:
doc_api5 = api5_api.SpcActiveDocument()
if doc_type == k_constants.ksDocumentSpecification:
doc_api5 = api5_api.SpcActiveDocument()
if doc_api5 and save_param is None:
rasterParJPG = doc_api5.RasterFormatParam()
rasterParJPG.Init()
rasterParJPG.colorBPP = 8
rasterParJPG.colorType = 3
rasterParJPG.extResolution = 96
rasterParJPG.format = 0
rasterParJPG.greyScale = False
if doc_api5 and 'rasterParJPG' not in locals():
rasterParJPG = doc_api5.RasterFormatParam()
rasterParJPG.Init()
rasterParJPG.colorBPP = 8
rasterParJPG.colorType = 3
rasterParJPG.extResolution = 96
rasterParJPG.format = 0
rasterParJPG.greyScale = False
# Сохраняем информацию о документе
docs_info.append({
'doc_api5': doc_api5,
'doc_path': doc_path,
'doc_name': doc_name,
'doc_type': doc_type
})
# Создаем папки и сохраняем файлы
for ext in ["jpg", "dxf"]:
path = os.path.join(doc_path, ext)
os.makedirs(path, exist_ok=True)
full_path = os.path.join(path, f"{doc_name}.{ext}")
try:
if ext == "jpg":
doc_api5.SaveAsToRasterFormat(full_path, rasterParJPG)
counters['jpg_created'] += 1
created_files['jpg'].append(full_path)
print(f"Создан JPG: {full_path}")
# Загружаем изображение для PDF
img = Image.open(full_path)
if 'images' not in locals():
images = []
images.append(img)
elif ext == "dxf":
doc_api5.ksSaveToDXF(full_path)
counters['dxf_created'] += 1
created_files['dxf'].append(full_path)
print(f"Создан DXF: {full_path}")
except Exception as e:
print(f"Ошибка при создании {ext.upper()}: {str(e)}")
counters['errors'] += 1
result.append(f"Документ #{stats['processed_docs']}: {doc_name}")
except Exception as e:
print(f"Ошибка при обработке документа {i}: {str(e)}")
counters['errors'] += 1
stats['errors'] += 1
result.append(f"[ОШИБКА] Документ #{i+1}: {str(e)}")
# Создаем PDF отчет, если есть изображения
if 'images' in locals() and images:
# Обрабатываем каждый документ для сохранения JPG и DXF
for doc_info in docs_info:
try:
desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
pdf_filename = f"{first_doc_name}_pages.pdf"
pdf_output_path = os.path.join(desktop_path, pdf_filename)
for ext in ["jpg", "dxf"]:
path = f"{doc_info['doc_path']}{ext}/"
filename = f"{doc_info['doc_name']}.{ext}"
full_path = os.path.join(path, filename)
# Создаем титульную страницу
title_image = Image.new("RGB", (images[0].width, 200), color="white")
draw = ImageDraw.Draw(title_image)
try:
font = ImageFont.truetype("arial.ttf", size=48)
except:
font = ImageFont.load_default()
title_text = f"{first_doc_name}\nВсего страниц: {len(images)}"
draw.text((10, 50), title_text, fill="black", font=font, spacing=10)
images.insert(0, title_image)
if not os.path.exists(path):
os.makedirs(path)
stats['created_files'][f"{ext}_dirs"].append(path)
if ext == "jpg":
doc_info['doc_api5'].SaveAsToRasterFormat(full_path, rasterParJPG)
stats['jpg_created'] += 1
stats['created_files']['jpg_files'].append(full_path)
img = Image.open(full_path)
images.append(img)
if ext == "dxf":
doc_info['doc_api5'].ksSaveToDXF(full_path)
stats['dxf_created'] += 1
stats['created_files']['dxf_files'].append(full_path)
# Сохраняем PDF
images[0].save(
pdf_output_path,
"PDF",
resolution=96.0,
save_all=True,
append_images=images[1:],
)
counters['pdf_created'] += 1
created_files['pdf'] = pdf_output_path
print(f"\nСоздан PDF отчет: {pdf_output_path}")
except Exception as e:
print(f"Ошибка при создании PDF: {str(e)}")
counters['errors'] += 1
stats['errors'] += 1
result.append(f"[ОШИБКА] При сохранении {doc_info['doc_name']}: {str(e)}")
# Формируем итоговый отчет
report = [
# Если есть изображения, создаем PDF
if images and docs_info:
first_doc_path = docs_info[0]['doc_path']
pdf_path = f"{first_doc_path}pdf/"
f"Всего обработано документов: {counters['total_processed']}",
f"Создано JPG файлов: {counters['jpg_created']}",
f"Создано DXF файлов: {counters['dxf_created']}",
f"Создано PDF отчетов: {counters['pdf_created']}",
f"Ошибок при обработке: {counters['errors']}",
]
if created_files['jpg']:
report.append("\nJPG файлы:")
report.extend(created_files['jpg'])
if created_files['dxf']:
report.append("\nDXF файлы:")
report.extend(created_files['dxf'])
if created_files['pdf']:
report.append("\nPDF отчет:")
report.append(created_files['pdf'])
if not os.path.exists(pdf_path):
os.makedirs(pdf_path)
stats['created_files']['pdf_dirs'].append(pdf_path)
return "\n".join(report)
pdf_filename = f"{first_doc_name}_pages.pdf"
pdf_output_path = os.path.join(pdf_path, pdf_filename)
# Создаем заглавную страницу
try:
font = ImageFont.truetype("arial.ttf", size=48)
except IOError:
font = ImageFont.load_default()
title_image = Image.new("RGB", (images[0].width, 200), color="white")
draw = ImageDraw.Draw(title_image)
title_text = f"{first_doc_name}\nКоличество страниц: {len(images)}"
draw.text((10, 50), title_text, fill="black", font=font, spacing=10)
images.insert(0, title_image)
# Сохраняем PDF
images[0].save(
pdf_output_path,
"PDF",
resolution=96.0,
save_all=True,
append_images=images[1:],
)
stats['pdf_created'] = True
stats['pdf_path'] = pdf_output_path
stats['created_files']['pdf_files'].append(pdf_output_path)
# Формируем итоговый отчёт
result.append("\n=== РЕЗУЛЬТАТЫ ===")
result.append(f"Обработано документов: {stats['processed_docs']}/{stats['total_docs']}")
result.append(f"Создано JPG-файлов: {stats['jpg_created']}")
result.append(f"Создано DXF-файлов: {stats['dxf_created']}")
result.append(f"PDF создан: {'Да' if stats['pdf_created'] else 'Нет'}")
result.append(f"Ошибок: {stats['errors']}\n")
if stats['pdf_created']:
result.append(f"PDF сохранён: {stats['pdf_path']}\n")
# Выводим список созданных файлов
result.append("Созданные файлы и папки:")
for file_type, files in stats['created_files'].items():
if files:
result.append(f"\n{file_type.replace('_', ' ').title()}:")
for f in files:
result.append(f"{f}")
except Exception as e:
return f"Критическая ошибка: {str(e)}"
result.append(f"\n[КРИТИЧЕСКАЯ ОШИБКА] {str(e)}")
return "\n".join(result)