Record Sources⚓︎
sources
⚓︎
Read-only source metadata attached to parsed schema records.
The parser stores original table cells separately from parsed values so custom validators and tools can report precise feature-file coordinates.
Info
Metadata is immutable after record construction. Transformation may change current values, but source cells preserve the original location and text.
RecordSource
dataclass
⚓︎
RecordSource(
item_id: Any | None,
row: int | None,
column: int | None,
cells: Mapping[str, TableCell],
source_uri: str | None = None,
)
Original table locations associated with one parsed schema record.
Attributes:
-
item_id(Any | None) –Parsed local ID for column-oriented records when available.
-
row(int | None) –Source row for a row-oriented record.
-
column(int | None) –Source key/ID column for a column-oriented record.
-
cells(Mapping[str, TableCell]) –Mapping from schema attribute names to their source cells.
-
source_uri(str | None) –URI of the source document when known.
Warning
Some fields may not have source cells, especially values produced by defaults for omitted optional fields.
create
classmethod
⚓︎
create(
*,
item_id: Any | None = None,
row: int | None = None,
column: int | None = None,
cells: Mapping[str, TableCell] | None = None,
source_uri: str | None = None,
) -> RecordSource
Create immutable metadata from parser-owned source values.
Parameters:
-
item_id(Any | None, default:None) –Parsed record ID when available.
-
row(int | None, default:None) –Source row for row-oriented records.
-
column(int | None, default:None) –Source key/ID column for column-oriented records.
-
cells(Mapping[str, TableCell] | None, default:None) –Mapping from schema field names to source cells.
-
source_uri(str | None, default:None) –URI of the source document when known.
Returns:
-
RecordSource–A frozen
RecordSourcewith a read-only cell mapping.
Info
The mapping is copied so later caller mutations cannot change record provenance.
source_for
⚓︎
Return the source cell for one schema attribute name.
Parameters:
-
field_name(str) –Python schema attribute name.
Returns:
-
TableCell–TableCellthat supplied the parsed value.
Raises:
-
KeyError–If the field has no recorded source cell.
Warning
Missing optional fields with defaults do not have source cells. Use this method when a validator is responding to a value that came from the feature table itself.