优化工作流自动匹配
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -30,6 +30,9 @@ class DocxWorkflow(Workflow[DocxWorkflowConfig, Document, Document], HTMLExporta
|
|||||||
sub_config.logger = config.logger
|
sub_config.logger = config.logger
|
||||||
|
|
||||||
def _pre_translate(self, document_original: Document):
|
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()
|
document = document_original.copy()
|
||||||
translate_config = self.config.translator_config
|
translate_config = self.config.translator_config
|
||||||
translator = DocxTranslator(translate_config)
|
translator = DocxTranslator(translate_config)
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ class PPTXWorkflow(Workflow[PPTXWorkflowConfig, Document, Document], HTMLExporta
|
|||||||
sub_config.logger = config.logger
|
sub_config.logger = config.logger
|
||||||
|
|
||||||
def _pre_translate(self, document_original: Document):
|
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()
|
document = document_original.copy()
|
||||||
translate_config = self.config.translator_config
|
translate_config = self.config.translator_config
|
||||||
translator = PPTXTranslator(translate_config)
|
translator = PPTXTranslator(translate_config)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class XlsxWorkflow(Workflow[XlsxWorkflowConfig, Document, Document], HTMLExporta
|
|||||||
suffix = document.suffix
|
suffix = document.suffix
|
||||||
converter_types = self._converter_factory.get(suffix.lower())
|
converter_types = self._converter_factory.get(suffix.lower())
|
||||||
if converter_types is None:
|
if converter_types is None:
|
||||||
raise ValueError(f"Xlsx工作流不支持{suffix}格式文件")
|
raise ValueError(f"该工作流不支持{suffix}格式,请转为xlsx或csv格式")
|
||||||
converter_type, converter_config = converter_types
|
converter_type, converter_config = converter_types
|
||||||
converter = converter_type(converter_config)
|
converter = converter_type(converter_config)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user