Skip to content

Parser Base

omniread.xlsx.parser_base

Summary

XLSX parser base implementation for OmniRead.

This module defines the XLSX-specific parser contract, extending the format-agnostic BaseParser with constraints appropriate for Office Open XML spreadsheet content.

Classes

XlsxParserBase

XlsxParserBase(content: Content)

Bases: BaseParser[T], Generic[T]

Base xlsx parser.

Notes

Responsibilities:

1
2
3
- This class enforces xlsx content-type compatibility and provides
  the extension point for implementing concrete xlsx parsing
  strategies.

Constraints:

1
2
- Concrete implementations must define the output type `T` and
  implement the `parse()` method.

Initialize the parser with content to be parsed.

Parameters:

Name Type Description Default
content Content

Content instance to be parsed.

required

Raises:

Type Description
ValueError

If the content type is not supported by this parser.

Attributes
supported_types class-attribute instance-attribute
supported_types = {XLSX}

Set of content types supported by this parser (XLSX only).

Functions
parse abstractmethod
parse() -> T

Parse xlsx content into a structured output.

Returns:

Name Type Description
T T

Parsed representation of type T.

Raises:

Type Description
Exception

Parsing-specific errors as defined by the implementation.

supports
supports() -> bool

Check whether this parser supports the content's type.

Returns:

Name Type Description
bool bool

True if the content type is supported; False otherwise.