toml-combine 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toml_combine/combiner.py +7 -4
- {toml_combine-0.2.0.dist-info → toml_combine-0.3.0.dist-info}/METADATA +2 -19
- {toml_combine-0.2.0.dist-info → toml_combine-0.3.0.dist-info}/RECORD +5 -5
- {toml_combine-0.2.0.dist-info → toml_combine-0.3.0.dist-info}/WHEEL +0 -0
- {toml_combine-0.2.0.dist-info → toml_combine-0.3.0.dist-info}/entry_points.txt +0 -0
toml_combine/combiner.py
CHANGED
@@ -4,7 +4,7 @@ import copy
|
|
4
4
|
import dataclasses
|
5
5
|
from collections.abc import Mapping, Sequence
|
6
6
|
from functools import partial
|
7
|
-
from typing import Any
|
7
|
+
from typing import Any, TypeVar
|
8
8
|
|
9
9
|
from . import exceptions
|
10
10
|
|
@@ -89,7 +89,10 @@ def override_sort_key(
|
|
89
89
|
return tuple(result)
|
90
90
|
|
91
91
|
|
92
|
-
|
92
|
+
T = TypeVar("T", dict, list, str, int, float, bool)
|
93
|
+
|
94
|
+
|
95
|
+
def merge_configs(a: T, b: T, /) -> T:
|
93
96
|
"""
|
94
97
|
Recursively merge two configuration dictionaries, with b taking precedence.
|
95
98
|
"""
|
@@ -100,7 +103,7 @@ def merge_configs(a: Any, b: Any, /) -> Any:
|
|
100
103
|
return b
|
101
104
|
|
102
105
|
result = a.copy()
|
103
|
-
for key, b_value in b.items():
|
106
|
+
for key, b_value in b.items(): # type: ignore
|
104
107
|
if a_value := a.get(key):
|
105
108
|
result[key] = merge_configs(a_value, b_value)
|
106
109
|
else:
|
@@ -183,4 +186,4 @@ def generate_for_mapping(
|
|
183
186
|
if mapping_matches_override(mapping=mapping, override=override):
|
184
187
|
result = merge_configs(result, override.config)
|
185
188
|
|
186
|
-
return
|
189
|
+
return result
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: toml-combine
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: A tool for combining complex configurations in TOML format.
|
5
5
|
Author-email: Joachim Jablon <ewjoachim@gmail.com>
|
6
6
|
License-Expression: MIT
|
@@ -131,8 +131,7 @@ list and use that name as a key. Also, yes, you'll loose ordering.
|
|
131
131
|
When you call the tool either with the CLI or the lib (see both below), you will have to
|
132
132
|
provide a mapping of the desired dimentions. These values will be compared to overrides
|
133
133
|
to apply overrides when relevant. It's ok to omit some dimensions, corresponding
|
134
|
-
overrides won't be selected.
|
135
|
-
dict under the `dimensions` key.
|
134
|
+
overrides won't be selected.
|
136
135
|
|
137
136
|
By default, the output is `toml` though you can switch to `json` with `--format=json`
|
138
137
|
|
@@ -160,7 +159,6 @@ result = toml_combine.combine(config_file=config_file, environment="staging")
|
|
160
159
|
|
161
160
|
print(result)
|
162
161
|
{
|
163
|
-
"dimensions": {"environment": "staging"},
|
164
162
|
"fruits": {"apple": {"color": "red"}, "orange": {"color": "orange"}}
|
165
163
|
}
|
166
164
|
```
|
@@ -207,9 +205,6 @@ $ uv run toml-combine example.toml --environment=production --service=frontend
|
|
207
205
|
registry = "gcr.io/my-project/"
|
208
206
|
service_account = "my-service-account"
|
209
207
|
name = "service-frontend"
|
210
|
-
[dimensions]
|
211
|
-
environment = "production"
|
212
|
-
service = "frontend"
|
213
208
|
|
214
209
|
[container]
|
215
210
|
image_name = "my-image-frontend"
|
@@ -220,9 +215,6 @@ $ toml-combine example.toml --environment=production --service=backend
|
|
220
215
|
registry = "gcr.io/my-project/"
|
221
216
|
service_account = "my-service-account"
|
222
217
|
name = "service-backend"
|
223
|
-
[dimensions]
|
224
|
-
environment = "production"
|
225
|
-
service = "backend"
|
226
218
|
|
227
219
|
[container]
|
228
220
|
image_name = "my-image-backend"
|
@@ -234,9 +226,6 @@ $ toml-combine example.toml --environment=staging --service=frontend
|
|
234
226
|
registry = "gcr.io/my-project/"
|
235
227
|
service_account = "my-service-account"
|
236
228
|
name = "service-frontend"
|
237
|
-
[dimensions]
|
238
|
-
environment = "staging"
|
239
|
-
service = "frontend"
|
240
229
|
|
241
230
|
[container]
|
242
231
|
image_name = "my-image-frontend"
|
@@ -247,9 +236,6 @@ $ toml-combine example.toml --environment=staging --service=backend
|
|
247
236
|
registry = "gcr.io/my-project/"
|
248
237
|
service_account = "my-service-account"
|
249
238
|
name = "service-backend"
|
250
|
-
[dimensions]
|
251
|
-
environment = "staging"
|
252
|
-
service = "backend"
|
253
239
|
|
254
240
|
[container]
|
255
241
|
image_name = "my-image-backend"
|
@@ -264,9 +250,6 @@ $ toml-combine example.toml --environment=dev --service=backend
|
|
264
250
|
registry = "gcr.io/my-project/"
|
265
251
|
service_account = "my-service-account"
|
266
252
|
name = "service-backend"
|
267
|
-
[dimensions]
|
268
|
-
environment = "dev"
|
269
|
-
service = "backend"
|
270
253
|
|
271
254
|
[container]
|
272
255
|
image_name = "my-image-backend"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
toml_combine/__init__.py,sha256=TDkOwwEM-nS6hOh79u9Qae6g2Q6VfANpPpnKGfSgu80,84
|
2
2
|
toml_combine/__main__.py,sha256=hmF8N8xX6UEApzbKTVZ-4E1HU5-rjgUkdXNLO-mF6vo,100
|
3
3
|
toml_combine/cli.py,sha256=hG03eDKz7xU-ydJIa1kDuu6WlFzNS3GTMJ6zals9M9c,2843
|
4
|
-
toml_combine/combiner.py,sha256=
|
4
|
+
toml_combine/combiner.py,sha256=RhhCevncnVvxFYNywvtVWkVMpiqtF0mq_APjg76Tg4Q,5546
|
5
5
|
toml_combine/exceptions.py,sha256=tAFTDRSg6d10bBruBhsasZXrNNgLTmr_nKfvIsRR_yU,991
|
6
6
|
toml_combine/lib.py,sha256=Iw7F8SCyQMlhaqSD2vtnmM6jbnrgzCZeX0d-LTM3VVg,1683
|
7
7
|
toml_combine/toml.py,sha256=hqWEdBQiM960uga_9A6gXRhWhT2gVZT8IiLRc3jkyT8,797
|
8
|
-
toml_combine-0.
|
9
|
-
toml_combine-0.
|
10
|
-
toml_combine-0.
|
11
|
-
toml_combine-0.
|
8
|
+
toml_combine-0.3.0.dist-info/METADATA,sha256=xWGk3SSYPwWdcnqiRthODPYSLo3SSl84d_nSwUk3wJU,7354
|
9
|
+
toml_combine-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
toml_combine-0.3.0.dist-info/entry_points.txt,sha256=dXUQNom54uZt_7ylEG81iNYMamYpaFo9-ItcZJU6Uzc,58
|
11
|
+
toml_combine-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|