Files
lyxy-document/scripts/config.py
lanyuanxiaoyao cf10458dd6 feat: 添加 doc/xls/ppt 旧格式文档支持
- 新增 DocReader,支持 markitdown 和 pypandoc-binary 解析器
- 新增 XlsReader,支持 unstructured、markitdown 和 pandas+xlrd 解析器
- 新增 PptReader,支持 markitdown 解析器
- 添加 olefile 依赖用于验证 OLE2 格式
- 更新 config.py 添加 doc/xls/ppt 依赖配置
- 更新 --advice 支持 doc/xls/ppt 格式
- 添加相应的测试用例
- 同步 specs 到主目录
2026-03-10 23:09:13 +08:00

134 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""统一配置类,集中管理所有配置项。"""
class Config:
"""统一配置类"""
# 编码检测
# 回退编码列表,当 chardet 检测失败时依次尝试
FALLBACK_ENCODINGS = ['utf-8', 'gbk', 'gb2312', 'latin-1']
# HTML 下载
# 下载超时时间(秒)
DOWNLOAD_TIMEOUT = 30
# HTTP User-Agent 标识
USER_AGENT = "lyxy-document/0.1.0"
# 日志
# 日志等级,默认只输出 ERROR 级别避免干扰 Markdown 输出
LOG_LEVEL = "ERROR"
# 依赖配置:按文件类型和平台组织
# 每个平台配置包含 python 版本要求None 表示使用默认)和依赖列表
DEPENDENCIES = {
"pdf": {
"default": {
"python": None,
"dependencies": [
"docling",
"unstructured[pdf]",
"markitdown[pdf]",
"pypdf",
"markdownify"
]
},
"Darwin-x86_64": {
"python": "3.12",
"dependencies": [
"docling==2.40.0",
"docling-parse==4.0.0",
"numpy<2",
"markitdown[pdf]",
"pypdf",
"markdownify"
]
}
},
"docx": {
"default": {
"python": None,
"dependencies": [
"docling",
"unstructured[docx]",
"markitdown[docx]",
"pypandoc-binary",
"python-docx",
"markdownify"
]
}
},
"xlsx": {
"default": {
"python": None,
"dependencies": [
"docling",
"unstructured[xlsx]",
"markitdown[xlsx]",
"pandas",
"tabulate"
]
}
},
"pptx": {
"default": {
"python": None,
"dependencies": [
"docling",
"unstructured[pptx]",
"markitdown[pptx]",
"python-pptx",
"markdownify"
]
}
},
"html": {
"default": {
"python": None,
"dependencies": [
"trafilatura",
"domscribe",
"markitdown",
"html2text",
"beautifulsoup4",
"httpx",
"chardet",
"pyppeteer",
"selenium"
]
}
},
"doc": {
"default": {
"python": None,
"dependencies": [
"markitdown[docx]",
"pypandoc-binary",
"olefile"
]
}
},
"xls": {
"default": {
"python": None,
"dependencies": [
"unstructured[xlsx]",
"markitdown[xls]",
"pandas",
"tabulate",
"xlrd",
"olefile"
]
}
},
"ppt": {
"default": {
"python": None,
"dependencies": [
"markitdown[pptx]",
"olefile"
]
}
}
}