caxton.core.protocols¶
Structural contracts. Implement these to plug in your own data source, output target or renderer — no registration or private implementation import required.
Data¶
Classes:
-
DataSource–Lazy row source used by semantic table data.
-
DataSourceInfo–Optional execution hints exposed by a data source.
-
RowAccessor–Read one exact field from one row.
-
Repeatability–
Attributes:
-
RowSourceInput(TypeAlias) –Row input accepted by the public table factories.
RowSourceInput
module-attribute
¶
Row input accepted by the public table factories.
A ready :class:DataSource, any iterable of rows, or one mapping row. Rows
themselves stay untyped: a row is read field by field through a
:class:RowAccessor, never introspected as a whole.
One bare dataclass, NamedTuple or attribute object is also accepted at
runtime as a single-row source. That shape is not expressible in a type that
still rejects scalars, so typed callers wrap it in a one-element sequence.
Built-in row accessors¶
Classes:
-
MappingRowAccessor–Read fields using exact mapping key semantics.
-
AttributeRowAccessor–Read exact attributes without masking descriptor failures.
-
DefaultRowAccessor–Select exact mapping or attribute semantics for each row.
Rendering and output¶
Classes:
-
Renderer–Backend adapter consuming one compatible family IR.
-
OutputSink–Destination accepting rendered binary chunks or raising on failure.
-
BinaryWritable–External binary buffer whose short writes are completed by adapters.
-
BinarySeekable–Seekable binary stream that can receive an artifact directly.
Attributes:
Templates¶
Classes:
-
TemplateRenderer–Renderer consuming a generic template compilation result.
-
TemplateInspector–Read-only adapter that discovers facts about one template source.
Renderer contracts and results¶
Classes:
-
WorkbookOperation–How rendering obtains the workbook that will receive compiled content.
-
ExecutionMode–Backend-neutral execution preference for a renderer.
-
DataSourceRequirements–Execution metadata collected without reading a table row source.
-
ExecutionRequirements–Backend-neutral constraints used to choose an execution plan.
-
RequiredCapabilities–Backend-independent requirements discovered from a semantic graph.
-
RendererCapabilities–IR versions and semantic features supported by a renderer.
-
RendererDescriptor–Stable metadata used before selecting and invoking a renderer.
-
RenderContext–Resolved invocation settings passed to a renderer.
-
RenderResult–Result of a completed rendering operation.
WorkbookOperation
¶
Bases: StrEnum
How rendering obtains the workbook that will receive compiled content.
ExecutionMode
¶
Bases: StrEnum
Backend-neutral execution preference for a renderer.
DataSourceRequirements
dataclass
¶
DataSourceRequirements(worksheet_index: int, table_index: int, repeatability: Repeatability = UNKNOWN, row_count: int | None = None)
Execution metadata collected without reading a table row source.
ExecutionRequirements
dataclass
¶
ExecutionRequirements(mode: ExecutionMode = AUTO, data_sources: tuple[DataSourceRequirements, ...] = (), append_only: bool = False, has_named_tables: bool = False, requires_buffering: bool = False)
Backend-neutral constraints used to choose an execution plan.
Attributes:
-
requires_single_pass(bool) –Whether source metadata forbids an implicit second data pass.
RequiredCapabilities
dataclass
¶
RequiredCapabilities(document_kind: DocumentKind, ir_versions: frozenset[int], features: frozenset[str] = frozenset(), workbook_operation: WorkbookOperation = CREATE_NEW_WORKBOOK, execution: ExecutionRequirements = ExecutionRequirements())
Backend-independent requirements discovered from a semantic graph.
RendererCapabilities
dataclass
¶
RendererCapabilities(ir_versions: Mapping[DocumentKind, frozenset[int]], features: frozenset[str] = frozenset(), workbook_operations: frozenset[WorkbookOperation] = frozenset((CREATE_NEW_WORKBOOK,)), execution_modes: frozenset[ExecutionMode] = frozenset((STANDARD,)))
IR versions and semantic features supported by a renderer.
Methods:
-
supports–Return whether every required version and feature is compatible.
supports
¶
supports(required: RequiredCapabilities) -> bool
Return whether every required version and feature is compatible.
RendererDescriptor
dataclass
¶
RendererDescriptor(name: str, version: str, formats: frozenset[str], mime_types: frozenset[str], extensions: frozenset[str], capabilities: RendererCapabilities, contract_version: int = RENDERER_CONTRACT_VERSION)
Stable metadata used before selecting and invoking a renderer.
RenderContext
dataclass
¶
RenderContext(format: str, backend: str, execution: ExecutionRequirements = ExecutionRequirements())
Resolved invocation settings passed to a renderer.