|
7 | 7 | @desc: |
8 | 8 | """ |
9 | 9 | import io |
10 | | -import logging |
11 | | - |
12 | | -import uuid_utils.compat as uuid |
| 10 | +import traceback |
13 | 11 | from functools import reduce |
14 | 12 | from io import BytesIO |
15 | 13 | from xml.etree.ElementTree import fromstring |
16 | 14 | from zipfile import ZipFile |
17 | 15 |
|
| 16 | +import uuid_utils.compat as uuid |
18 | 17 | from PIL import Image as PILImage |
19 | 18 | from openpyxl.drawing.image import Image as openpyxl_Image |
20 | 19 | from openpyxl.packaging.relationship import get_rels_path, get_dependents |
21 | 20 | from openpyxl.xml.constants import SHEET_DRAWING_NS, REL_NS, SHEET_MAIN_NS |
22 | 21 |
|
23 | | -from common.handle.base_parse_qa_handle import get_title_row_index_dict, get_row_value |
24 | 22 | from common.utils.logger import maxkb_logger |
25 | 23 | from knowledge.models import File |
26 | 24 |
|
@@ -76,7 +74,7 @@ def handle_images(deps, archive: ZipFile) -> []: |
76 | 74 | image_io = archive.read(dep.target) |
77 | 75 | image = openpyxl_Image(BytesIO(image_io)) |
78 | 76 | except Exception as e: |
79 | | - maxkb_logger.error(f"Error reading image {dep.target}: {e}") |
| 77 | + maxkb_logger.error(f"Error reading image {dep.target}: {e}, {traceback.format_exc()}") |
80 | 78 | continue |
81 | 79 | image.embed = dep.id # 文件rId |
82 | 80 | image.target = dep.target # 文件地址 |
@@ -107,6 +105,9 @@ def xlsx_embed_cells_images(buffer) -> {}: |
107 | 105 | image_excel_id_list = [_xl for _xl in |
108 | 106 | reduce(lambda x, y: [*x, *y], [sheet for sheet_id, sheet in sheet_list.items()], []) if |
109 | 107 | key in _xl] |
| 108 | + # print(key, img) |
| 109 | + if img is None: |
| 110 | + continue |
110 | 111 | if len(image_excel_id_list) > 0: |
111 | 112 | image_excel_id = image_excel_id_list[-1] |
112 | 113 | f = archive.open(img.target) |
|
0 commit comments