mcfonts.utils.importing

Utilities for importing provider dictionaries.

Module Contents

Functions

load_all(providers, json_path[, strict, mode])

Load every provider in the list providers.

load_provider(provider, json_path[, strict, mode])

Load a specific provider dictionary and return the equivalent Provider class.

mcfonts.utils.importing.load_all(providers, json_path, strict=False, mode='LA')

Load every provider in the list providers.

Parameters:
providers : list[dict[str, Any]]

A list of dictionaries of providers. This should be the value of the "providers" key in the JSON file.

json_path : pathlib.Path

The path to the JSON file at which this provider JSON is from.

strict : bool

Whether to raise or warn (and continue) on exceptions.

mode : str

What "mode" to load bitmap resources in.

  • "LA" - Grayscale

  • "RGBA" - Color

Returns:

A yield of Providers.

Return type:

collections.abc.Iterable[mcfonts.providers.base.Provider]

mcfonts.utils.importing.load_provider(provider, json_path, strict=False, mode='LA')

Load a specific provider dictionary and return the equivalent Provider class. Performs JSON schema validation.

Parameters:
provider : dict[str, Any]

A dictionary of a provider.

json_path : pathlib.Path

The real path to the JSON file at which this provider JSON is from.

strict : bool

Whether to raise or warn (and continue) on exceptions.

mode : str

What "mode" to load bitmap resources in.

  • "LA" - Grayscale

  • "RGBA" - Color

Returns:

A Provider instance.

Return type:

mcfonts.providers.base.Provider


Last update: 2023 November 30