serializefilters
Class info¶
🛈 DocStrings¶
deserialize
¶
Serialize given json-like object to given format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str
|
The data to deserialize |
required |
fmt
|
SerializeFormatStr
|
The serialization format |
required |
kwargs
|
Any
|
Keyword arguments passed to the loader function |
{}
|
Source code in src/jinjarope/serializefilters.py
28 29 30 31 32 33 34 35 36 37 38 |
|
dig
¶
Try to get data with given section path from a dict-list structure.
If a list is encountered and dig_yaml_lists is true, treat it like a list of {"identifier", {subdict}} items, as used in MkDocs config for plugins & extensions. If Key path does not exist, return None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
The data to dig into |
required |
sections
|
str
|
Sections to dig into |
()
|
keep_path
|
bool
|
Return result with original nesting |
False
|
dig_yaml_lists
|
bool
|
Also dig into single-key->value pairs, as often found in yaml. |
True
|
Source code in src/jinjarope/serializefilters.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
merge
¶
merge(
target: list | dict,
*source: list | dict,
deepcopy: bool = False,
mergers: dict[type, Callable[[Any, Any, Any], Any]] | None = None
) -> list | dict
Merge given data structures using mergers provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
list | dict
|
Data structure to merge into |
required |
source
|
list | dict
|
Data structures to merge into target |
()
|
deepcopy
|
bool
|
Whether to deepcopy the target |
False
|
mergers
|
dict[type, Callable[[Any, Any, Any], Any]] | None
|
Mergers with strategies for each type (default: additive) |
None
|
Source code in src/jinjarope/serializefilters.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
serialize
¶
Serialize given json-like object to given format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Any
|
The data to serialize |
required |
fmt
|
SerializeFormatStr
|
The serialization format |
required |
kwargs
|
Any
|
Keyword arguments passed to the dumper function |
{}
|
Source code in src/jinjarope/serializefilters.py
15 16 17 18 19 20 21 22 23 24 25 |
|