configaroo 0.5.0__py3-none-any.whl → 0.5.1__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 +17 -7
- {configaroo-0.5.0.dist-info → configaroo-0.5.1.dist-info}/METADATA +3 -3
- {configaroo-0.5.0.dist-info → configaroo-0.5.1.dist-info}/RECORD +7 -7
- {configaroo-0.5.0.dist-info → configaroo-0.5.1.dist-info}/WHEEL +0 -0
- {configaroo-0.5.0.dist-info → configaroo-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {configaroo-0.5.0.dist-info → configaroo-0.5.1.dist-info}/top_level.txt +0 -0
configaroo/__init__.py
CHANGED
configaroo/configuration.py
CHANGED
@@ -155,7 +155,7 @@ class Configuration(UserDict[str, Any]):
|
|
155
155
|
self,
|
156
156
|
model: type[BaseModel],
|
157
157
|
prefix: str = "",
|
158
|
-
types: type | UnionType = str | bool | int | float,
|
158
|
+
types: type | UnionType = str | bool | int | float, # pyright: ignore[reportArgumentType]
|
159
159
|
) -> Self:
|
160
160
|
"""Add environment variables to configuration based on the given model.
|
161
161
|
|
@@ -231,7 +231,8 @@ def print_configuration(
|
|
231
231
|
Configuration(config.model_dump()) if isinstance(config, BaseModel) else config
|
232
232
|
)
|
233
233
|
if section is None:
|
234
|
-
|
234
|
+
_print, _escape = _get_rich_print()
|
235
|
+
return _print_dict_as_tree(cfg, indent=indent, _print=_print, _escape=_escape)
|
235
236
|
|
236
237
|
cfg_section = cfg.get(section)
|
237
238
|
if cfg_section is None:
|
@@ -245,14 +246,20 @@ def print_configuration(
|
|
245
246
|
return print_configuration(Configuration({key: cfg_section}), indent=indent)
|
246
247
|
|
247
248
|
|
248
|
-
def _get_rich_print() ->
|
249
|
-
|
249
|
+
def _get_rich_print() -> tuple[
|
250
|
+
Callable[[str], None], Callable[[str], str]
|
251
|
+
]: # pragma: no cover
|
252
|
+
"""Initialize a Rich console if Rich is installed, otherwise use built-in print.
|
253
|
+
|
254
|
+
Include a function that can be used to escape markup.
|
255
|
+
"""
|
250
256
|
try:
|
251
257
|
from rich.console import Console # noqa: PLC0415
|
258
|
+
from rich.markup import escape # noqa: PLC0415
|
252
259
|
|
253
|
-
return Console().print
|
260
|
+
return Console().print, escape
|
254
261
|
except ImportError:
|
255
|
-
return print
|
262
|
+
return print, str
|
256
263
|
|
257
264
|
|
258
265
|
def _print_dict_as_tree(
|
@@ -260,6 +267,7 @@ def _print_dict_as_tree(
|
|
260
267
|
indent: int = 4,
|
261
268
|
current_indent: int = 0,
|
262
269
|
_print: Callable[[str], None] = print,
|
270
|
+
_escape: Callable[[str], str] = str,
|
263
271
|
) -> None:
|
264
272
|
"""Print a nested dictionary as a tree."""
|
265
273
|
for key, value in data.items():
|
@@ -270,9 +278,11 @@ def _print_dict_as_tree(
|
|
270
278
|
indent=indent,
|
271
279
|
current_indent=current_indent + indent,
|
272
280
|
_print=_print,
|
281
|
+
_escape=_escape,
|
273
282
|
)
|
274
283
|
else:
|
275
|
-
|
284
|
+
escaped_repr = _escape(repr(value))
|
285
|
+
_print(" " * current_indent + f"- {key}: {escaped_repr}")
|
276
286
|
|
277
287
|
|
278
288
|
def find_pyproject_toml(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: configaroo
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.1
|
4
4
|
Summary: Bouncy handling of configuration files
|
5
5
|
Author-email: Geir Arne Hjelle <geirarne@gmail.com>
|
6
6
|
Maintainer-email: Geir Arne Hjelle <geirarne@gmail.com>
|
@@ -33,9 +33,9 @@ Dynamic: license-file
|
|
33
33
|
[](https://pypi.org/project/configaroo/)
|
34
34
|
[](https://github.com/gahjelle/configaroo/blob/main/LICENSE)
|
35
35
|
[](https://github.com/astral-sh/ruff)
|
36
|
-
[](https://github.com/gahjelle/configaroo/actions/workflows/lint.yml)
|
36
|
+
[](https://github.com/gahjelle/configaroo/actions/workflows/lint.yml)
|
37
37
|
[](https://github.com/gahjelle/configaroo/actions/workflows/test.yml)
|
38
|
-
[](https://microsoft.github.io/pyright/)
|
39
39
|
|
40
40
|
Configaroo is a light configuration package for Python that offers the following features:
|
41
41
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
configaroo/__init__.py,sha256=
|
2
|
-
configaroo/configuration.py,sha256=
|
1
|
+
configaroo/__init__.py,sha256=vAghcz_xOnqTbFv0JlcHtG9gnff-BH2KsOfQEELVyos,477
|
2
|
+
configaroo/configuration.py,sha256=X_Wmw_NaY0vpGDZOTDI9aylqtgIDKKtLXl48KL2xd3M,11791
|
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.5.
|
9
|
-
configaroo-0.5.
|
10
|
-
configaroo-0.5.
|
11
|
-
configaroo-0.5.
|
12
|
-
configaroo-0.5.
|
8
|
+
configaroo-0.5.1.dist-info/licenses/LICENSE,sha256=rdeT6Y5bm0MUaERso7HRWpPj37Y1RD5li2lIQaMNJjc,1090
|
9
|
+
configaroo-0.5.1.dist-info/METADATA,sha256=pF6qO6hARbtFWyKkkssH9XuPTbJep18CBzxIhNQuOxU,2703
|
10
|
+
configaroo-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
configaroo-0.5.1.dist-info/top_level.txt,sha256=JVYICl1cWSjvSOZuZMYm976z9lnZaWtHVRSt373QCxg,11
|
12
|
+
configaroo-0.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|