# deepmerge
A tools to handle merging of
nested data structures in python.
## Example
```python
from deepmerge import Merger
my_merger = Merger(
# pass in a list of tuple, with the
# strategies you are looking to apply
# to each type.
[
(list, ["append"]),
(dict, ["merge"])
],
# next, choose the fallback strategies,
# applied to all other types:
["override"],
# finally, choose the strategies in
# the case where the types conflict:
["override"]
)
```
Strategies are passed as a list, and the
merge runs through each strategy sequentially,
and raises an exception if none are able to resolve
the merge.
You can also pass in your own merge functions, instead of a string.
Your function should take the arguments of (merger, path, base_value, value_to_merge_in).
A default merge does not exist, due to the
numerous choices that have to be made for every
merger. However, some very generic mergers are supplied:
* always_merger: will never raise a merge exception, and
will merge when possible.
* merge_or_raise: will merge when possible, raise an exception
when there is a conflict.
The best resource for now is the unit tests.
A tools to handle merging of
nested data structures in python.
## Example
```python
from deepmerge import Merger
my_merger = Merger(
# pass in a list of tuple, with the
# strategies you are looking to apply
# to each type.
[
(list, ["append"]),
(dict, ["merge"])
],
# next, choose the fallback strategies,
# applied to all other types:
["override"],
# finally, choose the strategies in
# the case where the types conflict:
["override"]
)
```
Strategies are passed as a list, and the
merge runs through each strategy sequentially,
and raises an exception if none are able to resolve
the merge.
You can also pass in your own merge functions, instead of a string.
Your function should take the arguments of (merger, path, base_value, value_to_merge_in).
A default merge does not exist, due to the
numerous choices that have to be made for every
merger. However, some very generic mergers are supplied:
* always_merger: will never raise a merge exception, and
will merge when possible.
* merge_or_raise: will merge when possible, raise an exception
when there is a conflict.
The best resource for now is the unit tests.
Release files for deepmerge 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deepmerge-0.0.1.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deepmerge-0.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.7 kB
Release files / deepmerge-0.0.1.tar.gz
| Download URL | deepmerge-0.0.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcd7cc83eba5f6b4d14bfc889d6a49615ae57509d7ff7ade99afde0ec1670a02
|
|
BLAKE2b-256 checksum How to use checksums |
4ce34425a1a7a6db4c25590c2d2c546a457ff2ef6e669d633d7fb827d40965db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / deepmerge-0.0.1-py2.py3-none-any.whl
| Download URL | deepmerge-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0714dd0d3a81b354729e60643f713fef83ad25a4326b42c343bfd58e1b0ae3e7
|
|
BLAKE2b-256 checksum How to use checksums |
c0b0ad05e108076ab643864f35ddf014964ee24fbad54589c1f895b26d3e4a77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |