dom_toml


Dom’s tools for Tom’s Obvious, Minimal Language.

Data:

Functions:

dump(​data, filename[, encoder])

Writes out data as TOML to the given file.

dumps(​data[, encoder])

Convert data to a TOML string.

load(​filename[, dict_, decoder])

Parse TOML from the given file.

loads(​s[, dict_, decoder])

Parse the given string as TOML.

_M = TypeVar(_M, bound=typing.MutableMapping[str, typing.Any])

Type:    TypeVar

Invariant TypeVar bound to typing.MutableMapping[str, typing.Any].

dump(data, filename, encoder=<class 'TomlEncoder'>)[source]

Writes out data as TOML to the given file.

Parameters
  • data (Mapping[str, Any])

  • filename (Union[str, Path, PathLike]) – The filename to write to.

  • encoder (Union[Type[TomlEncoder], TomlEncoder]) – The toml.TomlEncoder to use for constructing the output string. Default toml.encoder.TomlEncoder.

Return type

str

Returns

A string containing the TOML corresponding to data.

Changed in version 0.5.0: The default value for encoder changed from None to toml.TomlEncoder Explicitly passing encoder=None is deprecated and support will be removed in 1.0.0

dumps(data, encoder=<class 'TomlEncoder'>)[source]

Convert data to a TOML string.

Parameters
  • data (Mapping[str, Any])

  • encoder (Union[Type[TomlEncoder], TomlEncoder]) – The toml.TomlEncoder to use for constructing the output string. Default toml.encoder.TomlEncoder.

Return type

str

Returns

A string containing the TOML corresponding to data.

Changed in version 0.5.0: The default value for encoder changed from None to toml.TomlEncoder Explicitly passing encoder=None is deprecated and support will be removed in 1.0.0

load(filename, dict_=<class 'dict'>, decoder=<class 'TomlDecoder'>)[source]

Parse TOML from the given file.

Parameters
  • filename (Union[str, Path, PathLike]) – The filename to read from to.

  • dict_ (Type[~_M]) – The class of the returned data. Default dict.

  • decoder (Union[Type[TomlDecoder], TomlDecoder]) – The toml.TomlEncoder to use for constructing the output string. Default toml.decoder.TomlDecoder.

Return type

~_M

Returns

A mapping containing the TOML data.

Overloads

Changed in version 0.5.0:
  • The default value for decoder changed from None to toml.TomlDecoder Explicitly passing decoder=None is deprecated and support will be removed in 1.0.0

  • Instead, pass a decoder class or, if you use the dict_ option, an instance of the decoder class for dict_.

loads(s, dict_=<class 'dict'>, decoder=<class 'TomlDecoder'>)[source]

Parse the given string as TOML.

Parameters
  • s

  • dict_ (Type[~_M]) – The class of the returned data. Default dict.

  • decoder (Union[Type[TomlDecoder], TomlDecoder]) – The toml.TomlEncoder to use for constructing the output string. Default toml.decoder.TomlDecoder.

Return type

~_M

Returns

A mapping containing the TOML data.

Overloads

Changed in version 0.5.0:
  • The default value for decoder changed from None to toml.TomlDecoder Explicitly passing decoder=None is deprecated and support will be removed in 1.0.0

  • Instead, pass a decoder class or, if you use the dict_ option, an instance of the decoder class for dict_.