Ravenports generated: 24 Jan 2024 23:27
[ravenports.git] / bucket_5A / python-mergedeep
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               python-mergedeep
4 VERSION=                1.3.4
5 KEYWORDS=               python
6 VARIANTS=               v11 v12
7 SDESC[v11]=             Deep merge function for 🐍 (3.11)
8 SDESC[v12]=             Deep merge function for 🐍 (3.12)
9 HOMEPAGE=               https://github.com/clarketm/mergedeep
10 CONTACT=                Python_Automaton[python@ironwolf.systems]
11
12 DOWNLOAD_GROUPS=        main
13 SITES[main]=            PYPIWHL/2c/19/04f9b178c2d8a15b076c8b5140708fa6ffc5601fb6f1e975537072df5b2a
14 DISTFILE[1]=            mergedeep-1.3.4-py3-none-any.whl:main
15 DF_INDEX=               1
16 SPKGS[v11]=             single
17 SPKGS[v12]=             single
18
19 OPTIONS_AVAILABLE=      PY311 PY312
20 OPTIONS_STANDARD=       none
21 VOPTS[v11]=             PY311=ON PY312=OFF
22 VOPTS[v12]=             PY311=OFF PY312=ON
23
24 DISTNAME=               mergedeep-1.3.4.dist-info
25
26 GENERATED=              yes
27
28 [PY311].USES_ON=                        python:v11,wheel
29
30 [PY312].USES_ON=                        python:v12,wheel
31
32 [FILE:1935:descriptions/desc.single]
33 # [mergedeep]
34
35 [PyPi release]
36 [PyPi versions]
37 [Downloads]
38 [Conda Version]
39 [Conda Downloads]
40 [Documentation Status]
41
42 A deep merge function for 🐍.
43
44 [Check out the mergedeep docs]
45
46 ## Installation
47
48 ```bash
49 $ pip install mergedeep
50 ```
51
52 ## Usage
53
54 ```text
55 merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy =
56 Strategy.REPLACE) -> MutableMapping
57 ```
58
59 Deep merge without mutating the source dicts.
60
61 ```python3
62 from mergedeep import merge
63
64 a = {"keyA": 1}
65 b = {"keyB": {"sub1": 10}}
66 c = {"keyB": {"sub2": 20}}
67
68 merged = merge({}, a, b, c) 
69
70 print(merged)
71 # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
72 ```
73
74 Deep merge into an existing dict.
75 ```python3
76 from mergedeep import merge
77
78 a = {"keyA": 1}
79 b = {"keyB": {"sub1": 10}}
80 c = {"keyB": {"sub2": 20}}
81
82 merge(a, b, c) 
83
84 print(a)
85 # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}}
86 ```
87
88 ### Merge strategies:
89
90 1. Replace (*default*)
91
92 > `Strategy.REPLACE`
93
94 ```python3
95 # When `destination` and `source` keys are the same, replace the
96 `destination` value with one from `source` (default).
97
98 # Note: with multiple sources, the `last` (i.e. rightmost) source value
99 will be what appears in the merged result. 
100
101 from mergedeep import merge, Strategy
102
103 dst = {"key": [1, 2]}
104 src = {"key": [3, 4]}
105
106 merge(dst, src, strategy=Strategy.REPLACE) 
107 # same as: merge(dst, src)
108
109 print(dst)
110 # {"key": [3, 4]}
111 ```
112
113 2. Additive
114
115 > `Strategy.ADDITIVE`
116
117 ```python3
118 # When `destination` and `source` values are both the same additive
119 collection type, extend `destination` by adding values from `source`.
120 # Additive collection types include: `list`, `tuple`, `set`, and `Counter`
121
122 # Note: if the values are not additive collections of the same type, then
123 fallback to a `REPLACE` merge.
124
125 from mergedeep import merge, Strategy
126
127 dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})}
128 src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})}
129
130 merge(dst, src, strategy=Strategy.ADDITIVE) 
131
132 print(dst)
133
134
135 [FILE:111:distinfo]
136 70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307         6354 mergedeep-1.3.4-py3-none-any.whl
137