dom_toml
¶
Source code: dom_toml/__init__.py
Dom’s tools for Tom’s Obvious, Minimal Language.
Functions:
|
Writes out |
|
Convert |
|
Parse TOML from the given file. |
|
Parse the given string as TOML. |
-
dump
(data, filename, encoder=<class 'TomlEncoder'>)[source]¶ Writes out
data
as TOML to the given file.- Parameters
filename (
Union
[str
,Path
,PathLike
]) – The filename to write to.encoder (
Union
[Type
[TomlEncoder
],TomlEncoder
]) – TheTomlEncoder
to use for constructing the output string. Defaultdom_toml.encoder.TomlEncoder
.
- Return type
- Returns
A string containing the
TOML
corresponding todata
.
Changed in version 2.0.0:
encoder
must now be aTomlEncoder
type or instance.
-
dumps
(data, encoder=<class 'TomlEncoder'>)[source]¶ Convert
data
to a TOML string.- Parameters
encoder (
Union
[Type
[TomlEncoder
],TomlEncoder
]) – TheTomlEncoder
to use for constructing the output string. Defaultdom_toml.encoder.TomlEncoder
.
- Return type
- Returns
A string containing the
TOML
corresponding todata
.
Changed in version 2.0.0:
encoder
must now be aTomlEncoder
type or instance.
-
load
(filename, decoder=<class 'TomlDecoder'>)[source]¶ Parse TOML from the given file.
- Parameters
filename (
Union
[str
,Path
,PathLike
]) – The filename to read from to.decoder (
Union
[Type
[TomlDecoder
],TomlDecoder
]) – TheTomlEncoder
to use for constructing the output string. Defaultdom_toml.decoder.TomlDecoder
.
- Return type
- Returns
A mapping containing the
TOML
data.
Changed in version 2.0.0:
decoder
must now be aTomlDecoder
type or instance.
-
loads
(s, decoder=<class 'TomlDecoder'>)[source]¶ Parse the given string as TOML.
- Parameters
s (
str
)decoder (
Union
[Type
[TomlDecoder
],TomlDecoder
]) – TheTomlEncoder
to use for constructing the output string. Defaultdom_toml.decoder.TomlDecoder
.
- Return type
- Returns
A mapping containing the
TOML
data.
Changed in version 2.0.0:
decoder
must now be aTomlDecoder
type or instance.