Ini
π€ AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
provide.foundation.serialization.ini
¶
Functions¶
ini_dumps
¶
Serialize nested dictionary to INI format string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
dict[str, dict[str, str]]
|
Nested dictionary (sections -> key-value pairs) |
required |
include_default
|
bool
|
Whether to include DEFAULT section |
False
|
Returns:
| Type | Description |
|---|---|
str
|
INI format string |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If object cannot be serialized |
Example
ini_dumps({"section": {"key": "value"}}) '[section]\nkey = value\n\n'
Source code in provide/foundation/serialization/ini.py
ini_loads
¶
Deserialize INI format string to nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
INI format string to deserialize |
required |
use_cache
|
bool
|
Whether to use caching for this operation |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, str]]
|
Nested dictionary (sections -> key-value pairs) |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If string is not valid INI format |
Example
ini_loads('[section]\nkey = value') {'section': {'key': 'value'}}