Metadata

finalfusion metadata

class finalfusion.metadata.Metadata[source]

Bases: dict, finalfusion.io.Chunk

Embeddings metadata

Metadata can be used as a regular Python dict. For serialization, the contents need to be serializable through toml.dumps. Finalfusion assumes metadata to be a TOML formatted string.

Examples

>>> metadata = Metadata({'Some': 'value', 'number': 1})
>>> metadata
{'Some': 'value', 'number': 1}
>>> metadata['Some']
'value'
>>> metadata['Some'] = 'other value'
>>> metadata['Some']
'other value'
static chunk_identifier()finalfusion.io.ChunkIdentifier[source]

Get the ChunkIdentifier for this Chunk.

Returns

chunk_identifier

Return type

ChunkIdentifier

static read_chunk(file: BinaryIO)finalfusion.metadata.Metadata[source]

Read the Chunk and return it.

The file must be positioned before the contents of the Chunk but after its header.

Parameters

file (BinaryIO) – a finalfusion file containing the given Chunk

Returns

chunk – The chunk read from the file.

Return type

Chunk

write_chunk(file: BinaryIO)[source]

Write the Chunk to a file.

Parameters

file (BinaryIO) – Output file for the Chunk

finalfusion.metadata.load_metadata(file: Union[str, bytes, int, os.PathLike])finalfusion.metadata.Metadata[source]

Load a Metadata chunk from the given file.

Parameters

file (str, bytes, int, PathLike) – Finalfusion file with a metadata chunk.

Returns

metadata – The Metadata from the file.

Return type

Metadata

Raises

ValueError – If the file did not contain an Metadata chunk.