betty.porters.keyed_mapping module#

Keyed porters for portable mappings.

final class betty.porters.keyed_mapping.KeyedMappingPorter#

Bases: ProxyPorter, KeyedPorter, Generic

Make an existing porter that dumps to portable mappings, a keyed porter.

__init__(key: str, proxied: Porter[DataT], /)#
dump_keyed(data: DataT, /) tuple[str, PortableMapping]#

Dump the data to portable data and a portable primary key.

Raises:

betty.portable.error.NotPortable – Raised if any part of the data is not portable.

load_keyed(key: str, data: PortableData, /) DataT#

Create a new data instance from portable data and a portable primary key.

Raises:

betty.exception.HumanFacingException – Raised if the portable data is invalid.