data_merge
Tools for merging data.
Attributes¶
COMPREHENSIVE
module-attribute
¶
COMPREHENSIVE = 'comprehensive'
Comprehensively merge the two data structures.
- Scalars are overwritten by the new values
- lists are merged and de-duplicated
- dicts are recursively merged
DO_NOT_MERGE
module-attribute
¶
DO_NOT_MERGE = 'do-not-merge'
Do not merge the data, use the file path to determine what to do.
NESTED_OVERWRITE
module-attribute
¶
NESTED_OVERWRITE = 'nested-overwrite'
Merge deeply nested structures and overwrite at the lowest level; A deep dict.update()
.
Classes¶
Context
¶
Functions¶
comprehensive_merge
¶
comprehensive_merge(*args: MutableMapping) -> Any
Merges data comprehensively.
All arguments must be of the same type.
- Scalars are overwritten by the new values
- lists are merged and de-duplicated
- dicts are recursively merged
Parameters:
*args
-
List of dicts to merge with the first one the base
TYPE:
MutableMapping
DEFAULT:
()
Returns:
-
Any
-
The merged data
deep_merge
¶
deep_merge(*dicts: dict) -> dict
freeze_data
¶
freeze_data(obj: Any) -> Any
Check type and recursively return a new read-only object.
get_merge_strategy
¶
get_merge_strategy(
path: Path, merge_strategies: Dict[str, str]
) -> str