toml
NoneProxy
Bases: Item
Sentinel class taking the place of None when constructing tomlkit documents. These will be removed before serialization.
Source code in fancy_dataclass/toml.py
TOMLDataclass
Bases: DictFileSerializableDataclass
, TOMLSerializable
Dataclass mixin enabling default serialization of dataclass objects to and from TOML.
Source code in fancy_dataclass/toml.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
TOMLDataclassSettings
Bases: DictDataclassSettings
Class-level settings for the TOMLDataclass
mixin.
In addition to the settings inherited from DictDataclassSettings
, the following options may be set:
comment
: string that will be displayed as a top-level comment in the serialized TOMLdoc_as_comment
: ifTrue
, use the class's docstring as a top-level comment (this is overridden ifcomment
is set)
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 |