added podman, json and yaml
This commit is contained in:
@ -0,0 +1 @@
|
||||
pip
|
||||
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Travis Clarke <travis.m.clarke@gmail.com> (https://www.travismclarke.com/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -0,0 +1,154 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: mergedeep
|
||||
Version: 1.3.4
|
||||
Summary: A deep merge function for 🐍.
|
||||
Home-page: https://github.com/clarketm/mergedeep
|
||||
Author: Travis Clarke
|
||||
Author-email: travis.m.clarke@gmail.com
|
||||
License: UNKNOWN
|
||||
Platform: UNKNOWN
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Requires-Python: >=3.6
|
||||
Description-Content-Type: text/markdown
|
||||
|
||||
# [mergedeep](https://mergedeep.readthedocs.io/en/latest/)
|
||||
|
||||
[](https://pypi.org/project/mergedeep/)
|
||||
[](https://pypi.org/project/mergedeep/)
|
||||
[](https://pepy.tech/project/mergedeep)
|
||||
[](https://anaconda.org/conda-forge/mergedeep)
|
||||
[](https://anaconda.org/conda-forge/mergedeep)
|
||||
[](https://mergedeep.readthedocs.io/en/latest/?badge=latest)
|
||||
|
||||
A deep merge function for 🐍.
|
||||
|
||||
[Check out the mergedeep docs](https://mergedeep.readthedocs.io/en/latest/)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ pip install mergedeep
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```text
|
||||
merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping
|
||||
```
|
||||
|
||||
Deep merge without mutating the source dicts.
|
||||
|
||||
```python3
|
||||
from mergedeep import merge
|
||||
|
||||
a = {"keyA": 1}
|
||||
b = {"keyB": {"sub1": 10}}
|
||||
c = {"keyB": {"sub2": 20}}
|
||||
|
||||
merged = merge({}, a, b, c)
|
||||
|
||||
print(merged)
|
||||
# {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
|
||||
```
|
||||
|
||||
Deep merge into an existing dict.
|
||||
```python3
|
||||
from mergedeep import merge
|
||||
|
||||
a = {"keyA": 1}
|
||||
b = {"keyB": {"sub1": 10}}
|
||||
c = {"keyB": {"sub2": 20}}
|
||||
|
||||
merge(a, b, c)
|
||||
|
||||
print(a)
|
||||
# {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
|
||||
```
|
||||
|
||||
### Merge strategies:
|
||||
|
||||
1. Replace (*default*)
|
||||
|
||||
> `Strategy.REPLACE`
|
||||
|
||||
```python3
|
||||
# When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default).
|
||||
|
||||
# Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result.
|
||||
|
||||
from mergedeep import merge, Strategy
|
||||
|
||||
dst = {"key": [1, 2]}
|
||||
src = {"key": [3, 4]}
|
||||
|
||||
merge(dst, src, strategy=Strategy.REPLACE)
|
||||
# same as: merge(dst, src)
|
||||
|
||||
print(dst)
|
||||
# {"key": [3, 4]}
|
||||
```
|
||||
|
||||
2. Additive
|
||||
|
||||
> `Strategy.ADDITIVE`
|
||||
|
||||
```python3
|
||||
# When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`.
|
||||
# Additive collection types include: `list`, `tuple`, `set`, and `Counter`
|
||||
|
||||
# Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge.
|
||||
|
||||
from mergedeep import merge, Strategy
|
||||
|
||||
dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})}
|
||||
src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})}
|
||||
|
||||
merge(dst, src, strategy=Strategy.ADDITIVE)
|
||||
|
||||
print(dst)
|
||||
# {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})}
|
||||
```
|
||||
|
||||
3. Typesafe replace
|
||||
|
||||
> `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE`
|
||||
|
||||
```python3
|
||||
# When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge.
|
||||
|
||||
from mergedeep import merge, Strategy
|
||||
|
||||
dst = {"key": [1, 2]}
|
||||
src = {"key": {3, 4}}
|
||||
|
||||
merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE`
|
||||
# TypeError: destination type: <class 'list'> differs from source type: <class 'set'> for key: "key"
|
||||
```
|
||||
|
||||
4. Typesafe additive
|
||||
|
||||
> `Strategy.TYPESAFE_ADDITIVE`
|
||||
|
||||
```python3
|
||||
# When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge.
|
||||
|
||||
from mergedeep import merge, Strategy
|
||||
|
||||
dst = {"key": [1, 2]}
|
||||
src = {"key": {3, 4}}
|
||||
|
||||
merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE)
|
||||
# TypeError: destination type: <class 'list'> differs from source type: <class 'set'> for key: "key"
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © [**Travis Clarke**](https://blog.travismclarke.com/)
|
||||
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
mergedeep-1.3.4.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
mergedeep-1.3.4.dist-info/LICENSE,sha256=EVkr2dVmk8mH2oScB11jZpCRbQGkfKI0oUu88P4Xazc,1141
|
||||
mergedeep-1.3.4.dist-info/METADATA,sha256=8nHkB_zwURM7GrtHZfTUu9tjADgXfoka1G16_Uh_ubk,4336
|
||||
mergedeep-1.3.4.dist-info/RECORD,,
|
||||
mergedeep-1.3.4.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
|
||||
mergedeep-1.3.4.dist-info/top_level.txt,sha256=DbDDz9xNUAr-N7GSK2lAKoFC_aGex_L53GXDt0910AE,10
|
||||
mergedeep/__init__.py,sha256=quQFNpN7nAbu7UqS3VsfmRlXu89vC8RGH3Whr51IH1I,104
|
||||
mergedeep/__pycache__/__init__.cpython-311.pyc,,
|
||||
mergedeep/__pycache__/mergedeep.cpython-311.pyc,,
|
||||
mergedeep/__pycache__/test_mergedeep.cpython-311.pyc,,
|
||||
mergedeep/mergedeep.py,sha256=Lys3btFLe9hIKHsj9IgXPki0dahBeCnNmILqPTOckK4,4360
|
||||
mergedeep/test_mergedeep.py,sha256=R9B2GY9ZkCkhWKb6J4MEQsycyLnUUPqnDCr1_x7LJL8,13618
|
||||
@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.34.2)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@ -0,0 +1 @@
|
||||
mergedeep
|
||||
Reference in New Issue
Block a user