Files
docutranslate/docutranslate/workflow/interfaces.py
2025-08-04 18:35:26 +08:00

66 lines
2.0 KiB
Python

from pathlib import Path
from typing import Protocol, Self, TypeVar, runtime_checkable
from docutranslate.exporter.base import ExporterConfig
T_ExporterConfig = TypeVar("T_ExporterConfig", bound=ExporterConfig)
@runtime_checkable
class HTMLExportable(Protocol[T_ExporterConfig]):
def export_to_html(self, config: T_ExporterConfig | None = None) -> str:
...
def save_as_html(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...
@runtime_checkable
class MDExportable(Protocol[T_ExporterConfig]):
def export_to_markdown(self, config: T_ExporterConfig | None = None) -> str:
...
def save_as_markdown(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...
@runtime_checkable
class MDZIPExportable(Protocol[T_ExporterConfig]):
def export_to_markdown_zip(self, config: T_ExporterConfig | None = None) -> bytes:
...
def save_as_markdown_zip(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...
@runtime_checkable
class MDFormatsExportable(MDZIPExportable[T_ExporterConfig], MDExportable[T_ExporterConfig],Protocol):
...
@runtime_checkable
class TXTExportable(Protocol[T_ExporterConfig]):
def export_to_txt(self, config: T_ExporterConfig | None = None) -> str:
...
def save_as_txt(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...
@runtime_checkable
class JsonExportable(Protocol[T_ExporterConfig]):
def export_to_json(self, config: T_ExporterConfig | None = None) -> str:
...
def save_as_json(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...
@runtime_checkable
class XlsxExportable(Protocol[T_ExporterConfig]):
def export_to_xlsx(self, config: T_ExporterConfig | None = None) -> bytes:
...
def save_as_xlsx(self, name: str, output_dir: Path | str, config: T_ExporterConfig | None = None) -> Self:
...