Files
firecrawl__anydoc/python/anydoc/__init__.py
tomsideguide 52411911e4 feat(python): raise a ConvertError subclass per failure
- UnsupportedError, MalformedError, EncryptedError, ResourceLimitError,
  and MissingPartError all subclass ConvertError, so an existing
  `except anydoc.ConvertError` keeps catching every one of them
- the part or stream at fault rides on `part`, the limit crossed on
  `limit`, which is detail the JS bindings cannot carry
- an unreadable file still raises the OSError subclass any other read
  of it would
2026-08-05 18:53:00 +01:00

68 lines
1.3 KiB
Python

"""Convert documents to GitHub-Flavored Markdown."""
from typing import Literal
from anydoc._anydoc import (
Asset,
Block,
Cell,
CellSlot,
ConvertError,
Document,
EncryptedError,
ImageSource,
Inline,
LinkTarget,
List,
ListItem,
MalformedError,
MissingPartError,
Note,
ResourceLimitError,
Style,
Table,
UnsupportedError,
format_from_bytes,
format_from_extension,
format_from_path,
to_document,
to_markdown,
to_markdown_bytes,
)
Format = Literal[
"doc", "docx", "odt", "pdf", "ppt", "pptx", "rtf", "epub", "xlsx", "ods", "odp", "csv"
]
"""Input format, named after the extension that identifies it. Container
variants that share a parser (`.docm`, `.xlsm`, `.ppsx`, ...) map onto these
via `format_from_bytes` or `format_from_extension`."""
__all__ = [
"Asset",
"Block",
"Cell",
"CellSlot",
"ConvertError",
"Document",
"EncryptedError",
"Format",
"ImageSource",
"Inline",
"LinkTarget",
"List",
"ListItem",
"MalformedError",
"MissingPartError",
"Note",
"ResourceLimitError",
"Style",
"Table",
"UnsupportedError",
"format_from_bytes",
"format_from_extension",
"format_from_path",
"to_document",
"to_markdown",
"to_markdown_bytes",
]