From b26485c5cceedc55e9576c99e16cdd6713e7adc9 Mon Sep 17 00:00:00 2001 From: zosimovaa Date: Mon, 22 Dec 2025 22:48:57 +0300 Subject: [PATCH] Update code structure and improve readability --- .../handlers/excel2/excel_handler.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/mail_order_bot/email_processor/handlers/excel2/excel_handler.py diff --git a/src/mail_order_bot/email_processor/handlers/excel2/excel_handler.py b/src/mail_order_bot/email_processor/handlers/excel2/excel_handler.py new file mode 100644 index 0000000..ce729c4 --- /dev/null +++ b/src/mail_order_bot/email_processor/handlers/excel2/excel_handler.py @@ -0,0 +1,32 @@ +from io import BytesIO +from typing import Optional + + +class ExcelHandler: + """ + Класс для обработки Excel файлов. + Хранит файл в формате BytesIO и предоставляет методы для работы с ним. + """ + + def __init__(self, file_bytes: BytesIO): + """ + Инициализация обработчика Excel файла. + + Args: + file_bytes: Файл электронных таблиц в формате BytesIO + """ + if not isinstance(file_bytes, BytesIO): + raise TypeError("file_bytes должен быть экземпляром BytesIO") + + self.data: BytesIO = file_bytes + + def get_file(self) -> BytesIO: + """ + Возвращает сохраненный файл в формате BytesIO. + + Returns: + BytesIO: Файл электронных таблиц + """ + # Перемещаем указатель в начало файла для корректного чтения + self.data.seek(0) + return self.data