betty.serde.format package

Submodules

Module contents

Provide serialization formats.

betty.serde.format.FORMAT_REPOSITORY = <betty.serde.format.FormatRepository object>

The (de)serialization format plugin repository.

Read more about Serialization format plugins.

class betty.serde.format.Format[source]

Bases: Plugin

Defines a (de)serialization format.

abstractmethod dump(dump: Voidable[Dump]) str[source]

Serialize data.

abstractmethod classmethod extensions() set[str][source]

The file extensions this format can (de)serialize.

abstractmethod load(dump: str) Dump[source]

Deserialize data.

Raises:

FormatError – Raised when the dump could not be loaded.

exception betty.serde.format.FormatError[source]

Bases: AssertionFailed

Raised when data that is being deserialized is provided in an unknown (undeserializable) format.

final class betty.serde.format.FormatRepository[source]

Bases: PluginRepository[Format]

Exposes the available (de)serialization formats.

__init__()[source]
async extensions() set[str][source]

All file extensions supported by the formats in this repository.

async get(plugin_id: MachineName) type[Format][source]

Get a single plugin by its ID.

Raises:

PluginNotFound – if no plugin can be found for the given ID.

final class betty.serde.format.FormatStr[source]

Bases: Localizable

Localize and format a sequence of (de)serialization formats.

__init__(serde_formats: Sequence[type[Format]])[source]
localize(localizer: Localizer) LocalizedStr[source]

Localize self to a human-readable string.

betty.serde.format.format_for(available_formats: Sequence[type[Format]], extension: str) type[Format][source]

Get the (de)serialization format for the given file extension.