drytoml.merge module¶
Utilities and logic for handling inter-toml merges.
-
class
drytoml.merge.
TomlMerger
(container: tomlkit.container.Container, parser)¶ Bases:
object
Encapsulate toml merging strategies and procedures.
-
build_subparser
(value: tomlkit.items.Item)¶ Construct child parser from specific content.
- Parameters
value – The content of the TOML data to be parsed.
- Returns
The instantiated child parser.
-
merge_dict_like
(dct: Dict[tomlkit.items.Key, tomlkit.items.Item], breadcrumbs: List[tomlkit.items.Key])¶ Merge a dict-like object into a specific container position.
- Parameters
dct – The incoming data.
breadcrumbs – Location of the parent container for the incoming data merge.
-
merge_list_like
(values: List[tomlkit.items.Item], breadcrumbs: List[tomlkit.items.Key])¶ Merge sequence of values in a specific position of the container.
- Parameters
values – Incoming data to be merged one by one, in reversed order.
breadcrumbs – Location of the parent container for the incoming value merge.
-
merge_simple
(value: tomlkit.items.Item, breadcrumbs: List[tomlkit.items.Key])¶ Merge a value in a specific position of the container.
- Parameters
value – Incoming data to be merged.
breadcrumbs – Location of the parent container for the incoming value merge.
-
-
drytoml.merge.
deep_extend
(current: Union[tomlkit.items.Array, tomlkit.items.AoT], incoming: Union[tomlkit.items.Array, tomlkit.items.AoT]) → Union[tomlkit.items.Array, tomlkit.items.AoT]¶ Extend a container with another’s contents.
- Parameters
current – Container to extend (in-place).
incoming – Container to extend with.
- Returns
The recevied container, modified in-place.
-
drytoml.merge.
deep_merge
(current: tomlkit.items.Item, incoming: tomlkit.items.Item) → tomlkit.items.Item¶ Merge two items using a type-dependent strategy.
- Parameters
current – Item to merge into.
incoming – Item to merge from.
- Raises
NotImplementedError – Unable to merge received current and incoming item given their types.
- Returns
The current Item, after merging in-place.
-
drytoml.merge.
merge_targeted
(document: tomlkit.container.Container, incoming: tomlkit.container.Container, breadcrumbs: List[Union[str, int]]) → tomlkit.toml_document.TOMLDocument¶ Merge specific path contents from an incoming contianer into another.
- Parameters
document – The container to store the merge result.
incoming – The source of the incoming data.
breadcrumbs – Location of the incoming contend.
- Returns
The document, after merging in-place.