Coverage for src / quber / core / parsers / __init__.py: 100%
11 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-09-23 22:14 -0400
« prev ^ index » next coverage.py v7.14.0, created at 2026-09-23 22:14 -0400
1"""
2Document-level parsers.
4`Parser` is the engine-agnostic ABC for converting a source file into a
5`DoclingDocument` — the canonical in-memory document model (see core/README.md).
6`DoclingParser` is the abstract docling layer; the docling configuration is a
7type, not a flag: `TunedFinancialParser` (canonical default) and
8`LegacyDoclingParser` (pre-QUE-218). Use `parser_for_preset` to pick one.
10Table-only engines (Camelot+LLM) live behind a separate `TableExtractor`
11Protocol in `core.extractors`. The two paths intentionally do not compose
12at this layer; composition is a deferred design pass.
13"""
15from typing import TYPE_CHECKING, Any
17from quber.core.parsers.base import Parser
18from quber.core.parsers.mock import MockParser
19from quber.core.parsers.result import (
20 PageParse,
21 PageScore,
22 ParsedCell,
23 ParseResult,
24 TableProvenance,
25)
27if TYPE_CHECKING:
28 from quber.core.parsers.docling_parser import (
29 PARSERS_BY_PRESET,
30 DoclingParser,
31 LegacyDoclingParser,
32 TunedFinancialParser,
33 parser_for_preset,
34 )
36# The docling engine classes need the full `docling` package (the GPU extra).
37# The fuse cloud job imports this package only for `ParseResult` and must run
38# on the CPU image, so the engine names resolve lazily on first access
39# instead of at package import.
40ENGINE_EXPORTS = (
41 "PARSERS_BY_PRESET",
42 "DoclingParser",
43 "LegacyDoclingParser",
44 "TunedFinancialParser",
45 "parser_for_preset",
46)
49def __getattr__(name: str) -> Any:
50 if name in ENGINE_EXPORTS:
51 from quber.core.parsers import docling_parser
53 return getattr(docling_parser, name)
54 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
57__all__ = [
58 "PARSERS_BY_PRESET",
59 "DoclingParser",
60 "LegacyDoclingParser",
61 "MockParser",
62 "PageParse",
63 "PageScore",
64 "ParseResult",
65 "ParsedCell",
66 "Parser",
67 "TableProvenance",
68 "TunedFinancialParser",
69 "parser_for_preset",
70]