From 0f1d57f0cbbd52a5358f5ba7880274b2ce5dc038 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 30 Jun 2025 12:49:50 +0800 Subject: [PATCH] feat: enhance error logging for file processing in CSV, XLS, and DOC handlers --- apps/common/handle/impl/text/csv_split_handle.py | 2 ++ apps/common/handle/impl/text/doc_split_handle.py | 2 ++ apps/common/handle/impl/text/html_split_handle.py | 3 ++- apps/common/handle/impl/text/text_split_handle.py | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/common/handle/impl/text/csv_split_handle.py b/apps/common/handle/impl/text/csv_split_handle.py index e950ea395..569a16881 100644 --- a/apps/common/handle/impl/text/csv_split_handle.py +++ b/apps/common/handle/impl/text/csv_split_handle.py @@ -34,6 +34,8 @@ class CsvSplitHandle(BaseSplitHandle): file_name = os.path.basename(file.name) result = {'name': file_name, 'content': paragraphs} try: + if type(limit) is str: + limit = int(limit) reader = csv.reader(io.TextIOWrapper(io.BytesIO(buffer), encoding=detect(buffer)['encoding'])) try: title_row_list = reader.__next__() diff --git a/apps/common/handle/impl/text/doc_split_handle.py b/apps/common/handle/impl/text/doc_split_handle.py index 893c2dd1b..3063c3fab 100644 --- a/apps/common/handle/impl/text/doc_split_handle.py +++ b/apps/common/handle/impl/text/doc_split_handle.py @@ -195,6 +195,8 @@ class DocSplitHandle(BaseSplitHandle): def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): file_name = os.path.basename(file.name) try: + if type(limit) is str: + limit = int(limit) image_list = [] buffer = get_buffer(file) doc = Document(io.BytesIO(buffer)) diff --git a/apps/common/handle/impl/text/html_split_handle.py b/apps/common/handle/impl/text/html_split_handle.py index 78caf3d40..ca3ad66ab 100644 --- a/apps/common/handle/impl/text/html_split_handle.py +++ b/apps/common/handle/impl/text/html_split_handle.py @@ -46,7 +46,8 @@ class HTMLSplitHandle(BaseSplitHandle): def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): buffer = get_buffer(file) - + if type(limit) is str: + limit = int(limit) if pattern_list is not None and len(pattern_list) > 0: split_model = SplitModel(pattern_list, with_filter, limit) else: diff --git a/apps/common/handle/impl/text/text_split_handle.py b/apps/common/handle/impl/text/text_split_handle.py index 85354c5a5..6eb40f6a1 100644 --- a/apps/common/handle/impl/text/text_split_handle.py +++ b/apps/common/handle/impl/text/text_split_handle.py @@ -41,6 +41,8 @@ class TextSplitHandle(BaseSplitHandle): def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image): buffer = get_buffer(file) + if type(limit) is str: + limit = int(limit) if pattern_list is not None and len(pattern_list) > 0: split_model = SplitModel(pattern_list, with_filter, limit) else: