babelizer.config module

Library configuration used by the babelizer to wrap libraries.

class babelizer.config.BabelConfig(library: dict[str, Any] | None = None, build: dict[str, Any] | None = None, package: dict[str, Any] | None = None, info: dict[str, Any] | None = None, plugin: dict[str, Any] | None = None, ci: dict[str, Any] | None = None)[source]

Bases: Mapping[str, Any]

Babelizer configuration.

LOADERS: dict[str, Callable[[str], dict[str, Any]]] = {'toml': <function loads>, 'yaml': <function safe_load>}
__init__(library: dict[str, Any] | None = None, build: dict[str, Any] | None = None, package: dict[str, Any] | None = None, info: dict[str, Any] | None = None, plugin: dict[str, Any] | None = None, ci: dict[str, Any] | None = None)[source]

Configuration used by the babelizer to wrap a library.

Parameters:
  • library (dict, optional) – Information about the library being babelized.

  • build (dict, optional) – User-specified compiler flags.

  • package (dict, optional) – Name and requirements to build the babelized library.

  • info (dict, optional) – Descriptive information about the package.

  • plugin (dict, optional) – Deprecated, use package.

  • ci (dict, optional) – Information about how to set up continuous integration.

dump(fp: TextIOBase, fmt: str = 'toml') None[source]

Write serialized configuration to a file.

Parameters:
  • fp (file-like) – File object for output.

  • fmt (str, optional) – Format to serialize data.

format(fmt: str = 'toml') str[source]

Serialize configuration to output format.

Parameters:

fmt (str, optional) – Output format.

Returns:

config – Serialized configuration.

Return type:

str

format_toml() str[source]

Serialize configuration as TOML.

Returns:

Serialized configuration as a TOML-formatted string

Return type:

str

classmethod from_path(filepath: str) BabelConfig[source]

Create an instance of BabelConfig from a path-like object.

Parameters:

filepath (str) – Path to a babelizer configuration file.

Return type:

A BabelConfig instance.

classmethod from_stream(stream: TextIOBase, fmt: str = 'toml') BabelConfig[source]

Create an instance of BabelConfig from a file-like object.

Parameters:
  • stream (file-like) – File object with a babelizer configuration

  • fmt (str, optional) – File format.

Returns:

A BabelConfig instance.

Return type:

BabelConfig

static norm(config: dict[str, Any]) dict[str, Any][source]

Ensure current style is used in babelizer configuration.

Parameters:

config (dict) – Configuration to babelize a library.

Returns:

A dict of babelizer configuration.

Return type:

dict

static validate(config: dict[str, Any]) None[source]

Ensure babelizer configuration is valid.

Parameters:

config (dict) – Configuration to babelize a library.

Raises:

ValidationError – If configuration is not valid.