Files
omniread/omniread/xlsx/parser_base.py

56 lines
1.3 KiB
Python

"""
# 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.
"""
from typing import Generic, TypeVar
from abc import abstractmethod
from omniread.core.content import ContentType
from omniread.core.parser import BaseParser
T = TypeVar("T")
class XlsxParserBase(BaseParser[T], Generic[T]):
"""
Base xlsx parser.
Notes:
**Responsibilities:**
- This class enforces xlsx content-type compatibility and provides
the extension point for implementing concrete xlsx parsing
strategies.
**Constraints:**
- Concrete implementations must define the output type `T` and
implement the `parse()` method.
"""
supported_types = {ContentType.XLSX}
"""
Set of content types supported by this parser (XLSX only).
"""
@abstractmethod
def parse(self) -> T:
"""
Parse xlsx content into a structured output.
Returns:
T:
Parsed representation of type `T`.
Raises:
Exception:
Parsing-specific errors as defined by the implementation.
"""
raise NotImplementedError