configaroo 0.5.1__py3-none-any.whl → 0.6.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.
- configaroo/__init__.py +1 -1
- configaroo/configuration.py +16 -4
- {configaroo-0.5.1.dist-info → configaroo-0.6.0.dist-info}/METADATA +1 -1
- {configaroo-0.5.1.dist-info → configaroo-0.6.0.dist-info}/RECORD +7 -7
- {configaroo-0.5.1.dist-info → configaroo-0.6.0.dist-info}/WHEEL +0 -0
- {configaroo-0.5.1.dist-info → configaroo-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {configaroo-0.5.1.dist-info → configaroo-0.6.0.dist-info}/top_level.txt +0 -0
configaroo/__init__.py
CHANGED
configaroo/configuration.py
CHANGED
@@ -221,7 +221,11 @@ class Configuration(UserDict[str, Any]):
|
|
221
221
|
|
222
222
|
|
223
223
|
def print_configuration(
|
224
|
-
config: Configuration | BaseModel,
|
224
|
+
config: Configuration | BaseModel,
|
225
|
+
section: str | None = None,
|
226
|
+
*,
|
227
|
+
skip_none: bool = False,
|
228
|
+
indent: int = 4,
|
225
229
|
) -> None:
|
226
230
|
"""Pretty print a configuration.
|
227
231
|
|
@@ -232,7 +236,9 @@ def print_configuration(
|
|
232
236
|
)
|
233
237
|
if section is None:
|
234
238
|
_print, _escape = _get_rich_print()
|
235
|
-
return _print_dict_as_tree(
|
239
|
+
return _print_dict_as_tree(
|
240
|
+
cfg, skip_none=skip_none, indent=indent, _print=_print, _escape=_escape
|
241
|
+
)
|
236
242
|
|
237
243
|
cfg_section = cfg.get(section)
|
238
244
|
if cfg_section is None:
|
@@ -240,10 +246,12 @@ def print_configuration(
|
|
240
246
|
raise KeyError(message) from None
|
241
247
|
|
242
248
|
if isinstance(cfg_section, Configuration):
|
243
|
-
return print_configuration(cfg_section, indent=indent)
|
249
|
+
return print_configuration(cfg_section, skip_none=skip_none, indent=indent)
|
244
250
|
|
245
251
|
*_, key = section.split(".")
|
246
|
-
return print_configuration(
|
252
|
+
return print_configuration(
|
253
|
+
Configuration({key: cfg_section}), skip_none=skip_none, indent=indent
|
254
|
+
)
|
247
255
|
|
248
256
|
|
249
257
|
def _get_rich_print() -> tuple[
|
@@ -264,6 +272,8 @@ def _get_rich_print() -> tuple[
|
|
264
272
|
|
265
273
|
def _print_dict_as_tree(
|
266
274
|
data: dict[str, Any] | UserDict[str, Any] | Configuration,
|
275
|
+
*,
|
276
|
+
skip_none: bool = False,
|
267
277
|
indent: int = 4,
|
268
278
|
current_indent: int = 0,
|
269
279
|
_print: Callable[[str], None] = print,
|
@@ -271,6 +281,8 @@ def _print_dict_as_tree(
|
|
271
281
|
) -> None:
|
272
282
|
"""Print a nested dictionary as a tree."""
|
273
283
|
for key, value in data.items():
|
284
|
+
if skip_none and value is None:
|
285
|
+
continue
|
274
286
|
if isinstance(value, dict | UserDict | Configuration):
|
275
287
|
_print(" " * current_indent + f"- {key}")
|
276
288
|
_print_dict_as_tree(
|
@@ -1,12 +1,12 @@
|
|
1
|
-
configaroo/__init__.py,sha256=
|
2
|
-
configaroo/configuration.py,sha256=
|
1
|
+
configaroo/__init__.py,sha256=6DOyBxg4xOCjHc9qVERA9NZ3VZD0rnKBPPoXaXFKSjY,477
|
2
|
+
configaroo/configuration.py,sha256=z8zcdcAONtIE9M1xppf40iOVHfkp4x-TdTzmAUlpt-o,12032
|
3
3
|
configaroo/exceptions.py,sha256=GfLf3CLfHStiQjvdS7ZAtrKF9gmGL_8biFLayue6J0M,772
|
4
4
|
configaroo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
configaroo/loaders/__init__.py,sha256=XQrFwCMWzQ71ykaZFPmYysDz12y_elPqxWhUMQCsq3s,1076
|
6
6
|
configaroo/loaders/json.py,sha256=fT2Lg4hPM2BuwqrDsP7bcJlepAdmEh2iKU-YVK4KmIA,306
|
7
7
|
configaroo/loaders/toml.py,sha256=jw9U78Lf-GMA8QmGIM8xMBqOhPaa8ITSMAhhN1ZNyng,256
|
8
|
-
configaroo-0.
|
9
|
-
configaroo-0.
|
10
|
-
configaroo-0.
|
11
|
-
configaroo-0.
|
12
|
-
configaroo-0.
|
8
|
+
configaroo-0.6.0.dist-info/licenses/LICENSE,sha256=rdeT6Y5bm0MUaERso7HRWpPj37Y1RD5li2lIQaMNJjc,1090
|
9
|
+
configaroo-0.6.0.dist-info/METADATA,sha256=X4GSPIJMqNWSPufdbS2jgQ5Dma_WJ08ubKP57MsZ6l0,2703
|
10
|
+
configaroo-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
configaroo-0.6.0.dist-info/top_level.txt,sha256=JVYICl1cWSjvSOZuZMYm976z9lnZaWtHVRSt373QCxg,11
|
12
|
+
configaroo-0.6.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|