优化工作流自动匹配

This commit is contained in:
xunbu
2025-12-12 21:37:04 +08:00
parent 471e3ec2d5
commit 26446c0ec8
4 changed files with 8 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -30,6 +30,9 @@ class DocxWorkflow(Workflow[DocxWorkflowConfig, Document, Document], HTMLExporta
sub_config.logger = config.logger
def _pre_translate(self, document_original: Document):
suffix = document_original.suffix.lower() if document_original.suffix else ""
if suffix != ".docx":
raise ValueError(f"该工作流不支持{suffix}格式,请转为.docx格式")
document = document_original.copy()
translate_config = self.config.translator_config
translator = DocxTranslator(translate_config)

View File

@@ -30,6 +30,9 @@ class PPTXWorkflow(Workflow[PPTXWorkflowConfig, Document, Document], HTMLExporta
sub_config.logger = config.logger
def _pre_translate(self, document_original: Document):
suffix = document_original.suffix.lower() if document_original.suffix else ""
if suffix != ".pptx":
raise ValueError(f"该工作流不支持{suffix}格式,请转为.pptx格式")
document = document_original.copy()
translate_config = self.config.translator_config
translator = PPTXTranslator(translate_config)

View File

@@ -46,7 +46,7 @@ class XlsxWorkflow(Workflow[XlsxWorkflowConfig, Document, Document], HTMLExporta
suffix = document.suffix
converter_types = self._converter_factory.get(suffix.lower())
if converter_types is None:
raise ValueError(f"Xlsx工作流不支持{suffix}格式文件")
raise ValueError(f"工作流不支持{suffix}格式请转为xlsx或csv格式")
converter_type, converter_config = converter_types
converter = converter_type(converter_config)