Fix linting

This commit is contained in:
yangdx
2025-02-19 01:39:25 +08:00
parent d34dbc5717
commit 8196df83f8

View File

@@ -1363,7 +1363,7 @@ def create_app(args):
case ".xlsx": case ".xlsx":
if not pm.is_installed("openpyxl"): if not pm.is_installed("openpyxl"):
pm.install("openpyxl") pm.install("openpyxl")
from openpyxl import load_workbook from openpyxl import load_workbook # type: ignore
from io import BytesIO from io import BytesIO
xlsx_file = BytesIO(file) xlsx_file = BytesIO(file)
@@ -1371,7 +1371,13 @@ def create_app(args):
for sheet in wb: for sheet in wb:
content += f"Sheet: {sheet.title}\n" content += f"Sheet: {sheet.title}\n"
for row in sheet.iter_rows(values_only=True): for row in sheet.iter_rows(values_only=True):
content += "\t".join(str(cell) if cell is not None else "" for cell in row) + "\n" content += (
"\t".join(
str(cell) if cell is not None else ""
for cell in row
)
+ "\n"
)
content += "\n" content += "\n"
case _: case _:
logging.error( logging.error(
@@ -1383,12 +1389,18 @@ def create_app(args):
if content: if content:
has_new_docs = await rag.apipeline_enqueue_documents(content) has_new_docs = await rag.apipeline_enqueue_documents(content)
if has_new_docs: if has_new_docs:
logging.info(f"Successfully processed and enqueued file: {file_path.name}") logging.info(
f"Successfully processed and enqueued file: {file_path.name}"
)
else: else:
logging.info(f"File content already exists, skipping: {file_path.name}") logging.info(
f"File content already exists, skipping: {file_path.name}"
)
return True return True
else: else:
logging.error(f"No content could be extracted from file: {file_path.name}") logging.error(
f"No content could be extracted from file: {file_path.name}"
)
return False return False
except Exception as e: except Exception as e: