From 09904aefdc82ece7ff7ead17841fdc1abf25c995 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 8 Mar 2026 22:56:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20BaseReader=20?= =?UTF-8?q?=E4=B8=AD=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=20supported=5Fext?= =?UTF-8?q?ensions=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从 BaseReader 抽象基类及所有 Reader 子类中移除 supported_extensions 属性,该属性在代码库中从未被实际调用,仅作为元数据存在。 --- scripts/readers/base.py | 6 ------ scripts/readers/docx/__init__.py | 4 ---- scripts/readers/html/__init__.py | 4 ---- scripts/readers/pdf/__init__.py | 4 ---- scripts/readers/pptx/__init__.py | 4 ---- scripts/readers/xlsx/__init__.py | 4 ---- 6 files changed, 26 deletions(-) diff --git a/scripts/readers/base.py b/scripts/readers/base.py index 0a07aad..97edcfa 100644 --- a/scripts/readers/base.py +++ b/scripts/readers/base.py @@ -8,12 +8,6 @@ from typing import List, Optional, Tuple class BaseReader(ABC): """文档阅读器基类。""" - @property - @abstractmethod - def supported_extensions(self) -> List[str]: - """返回支持的文件扩展名列表(如 ['.docx', '.doc'])。""" - pass - @abstractmethod def supports(self, file_path: str) -> bool: """ diff --git a/scripts/readers/docx/__init__.py b/scripts/readers/docx/__init__.py index b4e243c..eec2fe3 100644 --- a/scripts/readers/docx/__init__.py +++ b/scripts/readers/docx/__init__.py @@ -27,10 +27,6 @@ PARSERS = [ class DocxReader(BaseReader): """DOCX 文件阅读器""" - @property - def supported_extensions(self) -> List[str]: - return [".docx"] - def supports(self, file_path: str) -> bool: return file_path.lower().endswith('.docx') diff --git a/scripts/readers/html/__init__.py b/scripts/readers/html/__init__.py index 295a9d5..ebbc476 100644 --- a/scripts/readers/html/__init__.py +++ b/scripts/readers/html/__init__.py @@ -26,10 +26,6 @@ PARSERS = [ class HtmlReader(BaseReader): """HTML/URL 文件阅读器""" - @property - def supported_extensions(self) -> List[str]: - return [".html", ".htm"] - def supports(self, file_path: str) -> bool: return is_url(file_path) or file_path.lower().endswith(('.html', '.htm')) diff --git a/scripts/readers/pdf/__init__.py b/scripts/readers/pdf/__init__.py index 3f8f589..9f175b0 100644 --- a/scripts/readers/pdf/__init__.py +++ b/scripts/readers/pdf/__init__.py @@ -27,10 +27,6 @@ PARSERS = [ class PdfReader(BaseReader): """PDF 文件阅读器""" - @property - def supported_extensions(self) -> List[str]: - return [".pdf"] - def supports(self, file_path: str) -> bool: return file_path.lower().endswith('.pdf') diff --git a/scripts/readers/pptx/__init__.py b/scripts/readers/pptx/__init__.py index eea4c00..6a92910 100644 --- a/scripts/readers/pptx/__init__.py +++ b/scripts/readers/pptx/__init__.py @@ -25,10 +25,6 @@ PARSERS = [ class PptxReader(BaseReader): """PPTX 文件阅读器""" - @property - def supported_extensions(self) -> List[str]: - return [".pptx"] - def supports(self, file_path: str) -> bool: return file_path.lower().endswith('.pptx') diff --git a/scripts/readers/xlsx/__init__.py b/scripts/readers/xlsx/__init__.py index 29fd84b..8856e97 100644 --- a/scripts/readers/xlsx/__init__.py +++ b/scripts/readers/xlsx/__init__.py @@ -25,10 +25,6 @@ PARSERS = [ class XlsxReader(BaseReader): """XLSX 文件阅读器""" - @property - def supported_extensions(self) -> List[str]: - return [".xlsx"] - def supports(self, file_path: str) -> bool: return file_path.lower().endswith('.xlsx')