toml
TOMLDataclass
Bases: DictFileSerializableDataclass
, TOMLSerializable
Dataclass mixin enabling default serialization of dataclass objects to and from TOML.
Source code in fancy_dataclass/toml.py
TOMLSerializable
Bases: TextFileSerializable
Mixin class enabling conversion of an object to/from TOML.
Source code in fancy_dataclass/toml.py
from_toml(fp, **kwargs)
classmethod
Constructs an object from a TOML file-like object (text or binary).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fp |
AnyIO
|
A readable file-like object |
required |
kwargs |
Any
|
Keyword arguments |
{}
|
Returns:
Type | Description |
---|---|
Self
|
Converted object of this class |
Source code in fancy_dataclass/toml.py
from_toml_string(s, **kwargs)
classmethod
Constructs an object from a TOML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str
|
TOML string |
required |
kwargs |
Any
|
Keyword arguments |
{}
|
Returns:
Type | Description |
---|---|
Self
|
Converted object of this class |
Source code in fancy_dataclass/toml.py
to_toml(fp, **kwargs)
Writes the object as TOML to a file-like object (text or binary). If binary, applies UTF-8 encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fp |
IOBase
|
A writable file-like object |
required |
kwargs |
Any
|
Keyword arguments |
{}
|
Source code in fancy_dataclass/toml.py
to_toml_string(**kwargs)
Converts the object into a TOML string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
Any
|
Keyword arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
Object rendered as a TOML string |