meta

Utility functions for merging metadata for multiple files.

class meta.MergeMetaAll[source]

Merge metadata by taking the set of values.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

property value

Get the merged value.

class meta.MergeMetaMax[source]

Merge metadata by taking the maximum value.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

class meta.MergeMetaMin[source]

Merge metadata by taking the minimum value.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

class meta.MergeMetaNameDict(value: str | None = None)[source]

Class to inject metadata into a name template.

Initialize the NameMetaFormatter with a value.

Parameters:

value – value to insert

class meta.MergeMetaOverride(value=None)[source]

Merge metadata by overriding the value.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

class meta.MergeMetaSum[source]

Merge metadata by adding the values.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

class meta.MergeMetaUnion[source]

Merge metadata by taking the union.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

property value

Get the merged value.

class meta.MergeMetaUnique(value=None)[source]

Merge metadata by taking the unique values.

add(value)[source]

Add a new value to the metadata.

property valid

Check if the value is valid.

meta.check_required(metadata: dict) list[source]

Check if the metadata dictionary contains all required keys.

Parameters:

metadata – metadata dictionary

Returns:

List of any missing required keys

meta.fix(name: str, metadata: dict) None[source]

Fix the metadata dictionary.

Parameters:
  • name – name of the file (for logging)

  • metadata – metadata dictionary

meta.make_name(metadata: dict) str[source]

Create a name for the merged file based on the metadata.

Parameters:

metadata – metadata dictionary

Returns:

merged file name

meta.merged_keys(files: dict, warn: bool = False) dict[source]

Merge metadata from multiple files into a single dictionary.

Parameters:
  • files – set of files to merge

  • warn – whether to warn about inconsistent metadata

Returns:

merged metadata

meta.parents(files: dict) list[str][source]

Retrieve all the parents from a set of files.

Parameters:

files – set of files to merge

Returns:

set of parents

meta.validate(name: str, metadata: dict, requirements: bool = True) bool[source]

Validate the metadata dictionary.

Parameters:
  • name – name of the file (for logging)

  • metadata – metadata dictionary

  • requirements – whether to check for required keys

Returns:

True if metadata is valid, False otherwise