Files
omniread/omniread/pdf/parser.py
Vishesh 'ironeagle' Bangotra 650d3a19e8 chore(release): 0.0.3
Squash-merge lib-standardisation: adopt repo standards across packaging,
tooling, docs, and CI.

- standardize pyproject.toml (canonical packaging, lint config, extras, GSDFC pydoclint)
- add py.typed marker, modernize type hints and Google-style docstrings
- nest generated docs under docs/lib and docs/mcp; add hand-written wiki
- adopt standard Type A PyPI CI pipeline (tag==version guard + quality gate)
- promote generated CHANGELOG.md; bump version to 0.0.3
2026-10-17 02:16:48 +05:30

63 lines
1.6 KiB
Python

"""
# Summary
PDF parser base implementations for OmniRead.
This module defines the **PDF-specific parser contract**, extending the
format-agnostic `BaseParser` with constraints appropriate for PDF content.
PDF parsers are responsible for interpreting binary PDF data and producing
structured representations suitable for downstream consumption.
"""
from abc import abstractmethod
from typing import Generic, TypeVar
from omniread.core.content import ContentType
from omniread.core.parser import BaseParser
T = TypeVar("T")
class PDFParser(BaseParser[T], Generic[T]):
"""
Base PDF parser.
Notes:
**Responsibilities:**
- This class enforces PDF content-type compatibility and provides
the extension point for implementing concrete PDF parsing strategies.
**Constraints:**
- Concrete implementations must define the output type `T` and
implement the `parse()` method.
"""
supported_types = {ContentType.PDF}
"""
Set of content types supported by this parser (PDF only).
"""
@abstractmethod
def parse(self) -> T:
"""
Parse PDF content into a structured output.
Returns:
T:
Parsed representation of type `T`.
Raises:
Exception:
Parsing-specific errors as defined by the implementation.
Notes:
**Responsibilities:**
- Implementations must fully interpret the PDF binary payload and
return a deterministic, structured output.
"""
raise NotImplementedError