refactor: 删除未使用的 detect_file_type 函数
- 移除 scripts/utils/file_detection.py 中的 _FILE_TYPE_VALIDATORS 字典 - 移除 scripts/utils/file_detection.py 中的 detect_file_type 函数 - 从 scripts/utils/__init__.py 中移除 detect_file_type 的导入和导出
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user