From 725b91374f50a62cf95c96001d37c2a23365c467 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 10 Mar 2026 23:31:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=20detect=5Ffile=5Ftype=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 scripts/utils/file_detection.py 中的 _FILE_TYPE_VALIDATORS 字典 - 移除 scripts/utils/file_detection.py 中的 detect_file_type 函数 - 从 scripts/utils/__init__.py 中移除 detect_file_type 的导入和导出 --- scripts/utils/__init__.py | 2 -- scripts/utils/file_detection.py | 18 ------------------ 2 files changed, 20 deletions(-) diff --git a/scripts/utils/__init__.py b/scripts/utils/__init__.py index 64cd1bb..f91d27f 100644 --- a/scripts/utils/__init__.py +++ b/scripts/utils/__init__.py @@ -10,7 +10,6 @@ from .file_detection import ( is_valid_ppt, is_html_file, is_url, - detect_file_type, ) __all__ = [ @@ -23,5 +22,4 @@ __all__ = [ "is_valid_ppt", "is_html_file", "is_url", - "detect_file_type", ] diff --git a/scripts/utils/file_detection.py b/scripts/utils/file_detection.py index 2bcffb4..5d81068 100644 --- a/scripts/utils/file_detection.py +++ b/scripts/utils/file_detection.py @@ -84,23 +84,5 @@ def is_url(input_str: str) -> bool: return input_str.startswith("http://") or input_str.startswith("https://") -_FILE_TYPE_VALIDATORS = { - ".docx": is_valid_docx, - ".pptx": is_valid_pptx, - ".xlsx": is_valid_xlsx, - ".pdf": is_valid_pdf, - ".doc": is_valid_doc, - ".xls": is_valid_xls, - ".ppt": is_valid_ppt, -} - - -def detect_file_type(file_path: str) -> Optional[str]: - """检测文件类型,返回 'docx'、'pptx'、'xlsx'、'pdf'、'doc'、'xls' 或 'ppt'""" - ext = os.path.splitext(file_path)[1].lower() - validator = _FILE_TYPE_VALIDATORS.get(ext) - if validator and validator(file_path): - return ext.lstrip(".") - return None