소스 검색

refactor: use dynamic suffix lists for file type checks in fast_api.py

myhloli 4 달 전
부모
커밋
a5a680b7b5
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      mineru/cli/fast_api.py

+ 2 - 2
mineru/cli/fast_api.py

@@ -11,7 +11,7 @@ from typing import List, Optional
 from loguru import logger
 from base64 import b64encode
 
-from mineru.cli.common import aio_do_parse, read_fn
+from mineru.cli.common import aio_do_parse, read_fn, pdf_suffixes, image_suffixes
 from mineru.utils.cli_parser import arg_parse
 from mineru.version import __version__
 
@@ -69,7 +69,7 @@ async def parse_pdf(
             file_path = Path(file.filename)
 
             # 如果是图像文件或PDF,使用read_fn处理
-            if file_path.suffix.lower() in [".pdf", ".png", ".jpeg", ".jpg"]:
+            if file_path.suffix.lower() in pdf_suffixes + image_suffixes:
                 # 创建临时文件以便使用read_fn
                 temp_path = Path(unique_dir) / file_path.name
                 with open(temp_path, "wb") as f: