all2md.parsers.mbox

MBOX mailbox archive to AST converter.

This module provides conversion from Unix mailbox format files (mbox, maildir, etc.) to AST representation. It supports streaming processing for large mailboxes and reuses the EML parser for individual message processing.

class all2md.parsers.mbox.MboxToAstConverter

Bases: BaseParser

Convert Unix mailbox archives to AST representation.

This converter processes mailbox format files (mbox, maildir, etc.) and builds an AST that can be rendered to various markdown flavors. It supports streaming processing for large mailboxes and reuses the EML parser for individual messages.

Parameters:
  • options (MboxOptions or None) – Conversion options

  • progress_callback (ProgressCallback or None) – Optional callback for progress updates during parsing

Initialize the MBOX parser with options and progress callback.

__init__(options: MboxOptions | None = None, progress_callback: Callable[[ProgressEvent], None] | None = None)

Initialize the MBOX parser with options and progress callback.

parse(input_data: str | Path | IO[bytes] | bytes) Document

Parse MBOX mailbox into an AST Document.

Parameters:

input_data (str, Path, IO[bytes], or bytes) – The input mailbox to parse. Can be: - File path (str or Path) - for file-based formats (mbox, mmdf, babyl) - Directory path (str or Path) - for directory-based formats (maildir, mh) - Not supported: IO[bytes] or bytes (mailbox requires file access)

Returns:

AST Document node representing the parsed mailbox structure

Return type:

Document

Raises:
extract_metadata(document: Any) DocumentMetadata

Extract metadata from mailbox.

Parameters:

document (Any) – Dictionary with mailbox information

Returns:

Extracted metadata

Return type:

DocumentMetadata