toml.py
TOML
dataclass
Bases: TOMLInput, Output[dict[str, Any]]
IO class for reading and writing TOML files.
Example usage:
>>> from pathlib import Path
>>> from ordeq_toml import TOML
>>> toml_path = Path("config.toml")
>>> io = TOML(path=toml_path)
>>> data = {"key": "value", "number": 42}
>>> io.save(data) # doctest: +SKIP
load(**load_options)
Load and parse the TOML file specified by the path attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**load_options
|
Any
|
Additional options to pass to the TOML loader. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representing the contents of the TOML file. |
save(data, **save_options)
Serialize the given data to a TOML file at the path attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
A dictionary to be serialized and saved as a TOML file. |
required |
**save_options
|
Any
|
Additional options to pass to the TOML dumper. |
{}
|
TOMLInput
dataclass
Bases: Input[dict[str, Any]]
IO class for reading TOML files.
Example usage:
>>> from pathlib import Path
>>> from ordeq_toml import TOMLInput
>>> toml_path = Path("config.toml")
>>> io = TOMLInput(path=toml_path)
>>> io.load() # doctest: +SKIP
load(**load_options)
Load and parse the TOML file specified by the path attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**load_options
|
Any
|
Additional options to pass to the TOML loader. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representing the contents of the TOML file. |