configaroo 0.1.0__tar.gz → 0.1.2__tar.gz
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-0.1.2/LICENSE +20 -0
- configaroo-0.1.2/PKG-INFO +40 -0
- configaroo-0.1.2/pyproject.toml +63 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/__init__.py +2 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/configuration.py +76 -29
- configaroo-0.1.2/src/configaroo.egg-info/PKG-INFO +40 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo.egg-info/SOURCES.txt +1 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo.egg-info/requires.txt +0 -1
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_configuration.py +67 -9
- configaroo-0.1.0/PKG-INFO +0 -21
- configaroo-0.1.0/pyproject.toml +0 -15
- configaroo-0.1.0/src/configaroo.egg-info/PKG-INFO +0 -21
- {configaroo-0.1.0 → configaroo-0.1.2}/README.md +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/setup.cfg +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/exceptions.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/loaders/__init__.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/loaders/json.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/loaders/toml.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo/py.typed +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo.egg-info/dependency_links.txt +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/src/configaroo.egg-info/top_level.txt +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_environment.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_json.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_loaders.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_toml.py +0 -0
- {configaroo-0.1.0 → configaroo-0.1.2}/tests/test_validation.py +0 -0
configaroo-0.1.2/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright © 2025 Geir Arne Hjelle
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: configaroo
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: Bouncy handling of configuration files
|
5
|
+
Author-email: Geir Arne Hjelle <geirarne@gmail.com>
|
6
|
+
Maintainer-email: Geir Arne Hjelle <geirarne@gmail.com>
|
7
|
+
License-Expression: MIT
|
8
|
+
Project-URL: homepage, https://github.com/gahjelle/configaroo
|
9
|
+
Project-URL: github, https://github.com/gahjelle/configaroo
|
10
|
+
Project-URL: issues, https://github.com/gahjelle/configaroo/issues
|
11
|
+
Project-URL: changelog, https://github.com/gahjelle/configaroo/blob/main/CHANGELOG.md
|
12
|
+
Keywords: configuration,configuration-management,toml,json
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
14
|
+
Classifier: Intended Audience :: Developers
|
15
|
+
Classifier: Natural Language :: English
|
16
|
+
Classifier: Operating System :: OS Independent
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Classifier: Typing :: Typed
|
24
|
+
Requires-Python: >=3.11
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
License-File: LICENSE
|
27
|
+
Requires-Dist: pydantic>=2.0
|
28
|
+
Requires-Dist: pyplugs>=0.4.0
|
29
|
+
Dynamic: license-file
|
30
|
+
|
31
|
+
# Configaroo - Bouncy Configuration Handling
|
32
|
+
|
33
|
+
Configaroo is a light configuration package for Python that offers the following features:
|
34
|
+
|
35
|
+
- Access configuration settings with dotted keys: `config.nested.key`
|
36
|
+
- Use different configuration file formats, including TOML and JSON
|
37
|
+
- Override key configuration settings with environment variables
|
38
|
+
- Validate a configuration based on a Pydantic model
|
39
|
+
- Convert the type of configuration values based on a Pydantic model
|
40
|
+
- Dynamically format certain configuration values
|
@@ -0,0 +1,63 @@
|
|
1
|
+
[build-system]
|
2
|
+
requires = ["setuptools>=61"]
|
3
|
+
build-backend = "setuptools.build_meta"
|
4
|
+
|
5
|
+
|
6
|
+
[project]
|
7
|
+
name = "configaroo"
|
8
|
+
description = "Bouncy handling of configuration files"
|
9
|
+
readme = "README.md"
|
10
|
+
authors = [{ name = "Geir Arne Hjelle", email = "geirarne@gmail.com" }]
|
11
|
+
maintainers = [{ name = "Geir Arne Hjelle", email = "geirarne@gmail.com" }]
|
12
|
+
requires-python = ">=3.11"
|
13
|
+
license = "MIT"
|
14
|
+
license-files = ["LICENSE"]
|
15
|
+
keywords = ["configuration", "configuration-management", "toml", "json"]
|
16
|
+
classifiers = [
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
18
|
+
"Intended Audience :: Developers",
|
19
|
+
"Natural Language :: English",
|
20
|
+
"Operating System :: OS Independent",
|
21
|
+
"Programming Language :: Python :: 3.11",
|
22
|
+
"Programming Language :: Python :: 3.12",
|
23
|
+
"Programming Language :: Python :: 3.13",
|
24
|
+
"Programming Language :: Python :: 3.14",
|
25
|
+
"Programming Language :: Python :: 3",
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
27
|
+
"Typing :: Typed",
|
28
|
+
]
|
29
|
+
dependencies = ["pydantic>=2.0", "pyplugs>=0.4.0"]
|
30
|
+
dynamic = ["version"]
|
31
|
+
|
32
|
+
[project.urls]
|
33
|
+
homepage = "https://github.com/gahjelle/configaroo"
|
34
|
+
github = "https://github.com/gahjelle/configaroo"
|
35
|
+
issues = "https://github.com/gahjelle/configaroo/issues"
|
36
|
+
changelog = "https://github.com/gahjelle/configaroo/blob/main/CHANGELOG.md"
|
37
|
+
|
38
|
+
[dependency-groups]
|
39
|
+
build = ["build>=1.2.2.post1", "twine>=6.1.0"]
|
40
|
+
dev = [
|
41
|
+
"bumpver>=2024.1130",
|
42
|
+
"ipython>=8.36.0",
|
43
|
+
"pytest>=8.3.5",
|
44
|
+
"ruff>=0.11.11",
|
45
|
+
"tomli-w>=1.2.0",
|
46
|
+
]
|
47
|
+
|
48
|
+
|
49
|
+
[tool.setuptools.dynamic]
|
50
|
+
version = { attr = "configaroo.__version__" }
|
51
|
+
|
52
|
+
[tool.bumpver]
|
53
|
+
current_version = "v0.1.2"
|
54
|
+
version_pattern = "vMAJOR.MINOR.PATCH"
|
55
|
+
commit_message = "bump version {old_version} -> {new_version}"
|
56
|
+
tag_message = "{new_version}"
|
57
|
+
commit = true
|
58
|
+
tag = true
|
59
|
+
push = false
|
60
|
+
|
61
|
+
[tool.bumpver.file_patterns]
|
62
|
+
"pyproject.toml" = ['current_version = "{version}"']
|
63
|
+
"src/configaroo/__init__.py" = ['__version__ = "MAJOR.MINOR.PATCH"']
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"""A dict-like configuration with support for envvars, validation and type conversion"""
|
2
2
|
|
3
|
+
import inspect
|
3
4
|
import os
|
5
|
+
import re
|
4
6
|
from collections import UserDict
|
5
7
|
from pathlib import Path
|
6
8
|
from typing import Any, Self, Type
|
7
9
|
|
8
|
-
import dotenv
|
9
10
|
from pydantic import BaseModel
|
10
11
|
|
11
12
|
from configaroo import loaders
|
@@ -27,7 +28,9 @@ class Configuration(UserDict):
|
|
27
28
|
) -> Self:
|
28
29
|
"""Read a Configuration from a file"""
|
29
30
|
config_dict = loaders.from_file(file_path, loader=loader)
|
30
|
-
return cls(
|
31
|
+
return cls(config_dict).initialize(
|
32
|
+
envs=envs, env_prefix=env_prefix, extra_dynamic=extra_dynamic, model=model
|
33
|
+
)
|
31
34
|
|
32
35
|
def initialize(
|
33
36
|
self,
|
@@ -51,7 +54,7 @@ class Configuration(UserDict):
|
|
51
54
|
"""Make sure nested sections have type Configuration"""
|
52
55
|
value = self.data[key]
|
53
56
|
if isinstance(value, dict | UserDict | Configuration):
|
54
|
-
return Configuration(
|
57
|
+
return Configuration(value)
|
55
58
|
else:
|
56
59
|
return value
|
57
60
|
|
@@ -76,39 +79,33 @@ class Configuration(UserDict):
|
|
76
79
|
|
77
80
|
def get(self, key: str, default: Any = None) -> Any:
|
78
81
|
"""Allow dotted keys when using .get()"""
|
79
|
-
if key
|
80
|
-
prefix, _, rest = key.partition(".")
|
81
|
-
try:
|
82
|
-
return self[prefix].get(rest, default=default)
|
83
|
-
except KeyError:
|
84
|
-
return default
|
85
|
-
else:
|
82
|
+
if key in self.data:
|
86
83
|
return self[key]
|
87
84
|
|
85
|
+
prefix, _, rest = key.partition(".")
|
86
|
+
try:
|
87
|
+
return self[prefix].get(rest, default=default)
|
88
|
+
except KeyError:
|
89
|
+
return default
|
90
|
+
|
88
91
|
def add(self, key: str, value: Any) -> Self:
|
89
92
|
"""Add a value, allow dotted keys"""
|
90
93
|
prefix, _, rest = key.partition(".")
|
91
|
-
if rest:
|
92
|
-
cls = type(self)
|
93
|
-
return self | {prefix: cls(**self.setdefault(prefix, {})).add(rest, value)}
|
94
|
-
else:
|
94
|
+
if not rest:
|
95
95
|
return self | {key: value}
|
96
|
+
cls = type(self)
|
97
|
+
return self | {prefix: cls(self.setdefault(prefix, {})).add(rest, value)}
|
96
98
|
|
97
|
-
def add_envs(self, envs: dict[str, str], prefix: str = ""
|
99
|
+
def add_envs(self, envs: dict[str, str], prefix: str = "") -> Self:
|
98
100
|
"""Add environment variables to configuration"""
|
99
|
-
if use_dotenv:
|
100
|
-
dotenv.load_dotenv()
|
101
|
-
|
102
101
|
for env, key in envs.items():
|
103
102
|
env_key = f"{prefix}{env}"
|
104
|
-
env_value
|
105
|
-
if env_value:
|
103
|
+
if env_value := os.getenv(env_key):
|
106
104
|
self = self.add(key, env_value)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
)
|
105
|
+
elif key not in self:
|
106
|
+
raise MissingEnvironmentVariableError(
|
107
|
+
f"required environment variable '{env_key}' not found"
|
108
|
+
)
|
112
109
|
return self
|
113
110
|
|
114
111
|
def parse_dynamic(self, extra: dict[str, Any] | None = None) -> Self:
|
@@ -116,15 +113,15 @@ class Configuration(UserDict):
|
|
116
113
|
cls = type(self)
|
117
114
|
variables = (
|
118
115
|
self.to_flat_dict()
|
119
|
-
| {"project_path":
|
116
|
+
| {"project_path": _find_pyproject_toml()}
|
120
117
|
| ({} if extra is None else extra)
|
121
118
|
)
|
122
119
|
return cls(
|
123
|
-
|
120
|
+
{
|
124
121
|
key: (
|
125
122
|
value.parse_dynamic(extra=variables)
|
126
123
|
if isinstance(value, Configuration)
|
127
|
-
else value
|
124
|
+
else _incomplete_format(value, variables)
|
128
125
|
if isinstance(value, str)
|
129
126
|
else value
|
130
127
|
)
|
@@ -140,7 +137,7 @@ class Configuration(UserDict):
|
|
140
137
|
def convert(self, model: Type[BaseModel]) -> Self:
|
141
138
|
"""Convert data types to match the given model"""
|
142
139
|
cls = type(self)
|
143
|
-
return cls(
|
140
|
+
return cls(model(**self.data).model_dump())
|
144
141
|
|
145
142
|
def to_dict(self) -> dict[str, Any]:
|
146
143
|
"""Dump the configuration into a Python dictionary"""
|
@@ -166,3 +163,53 @@ class Configuration(UserDict):
|
|
166
163
|
self[nested_key].to_flat_dict(_prefix=f"{_prefix}{nested_key}.").items()
|
167
164
|
)
|
168
165
|
}
|
166
|
+
|
167
|
+
|
168
|
+
def _find_pyproject_toml(
|
169
|
+
path: Path | None = None, _file_name: str = "pyproject.toml"
|
170
|
+
) -> Path:
|
171
|
+
"""Find a directory that contains a pyproject.toml file.
|
172
|
+
|
173
|
+
This searches the given directory and all direct parents. If a
|
174
|
+
pyproject.toml file isn't found, then the root of the file system is
|
175
|
+
returned.
|
176
|
+
"""
|
177
|
+
path = _get_foreign_path() if path is None else path
|
178
|
+
if (path / _file_name).exists() or path == path.parent:
|
179
|
+
return path.resolve()
|
180
|
+
else:
|
181
|
+
return _find_pyproject_toml(path.parent, _file_name=_file_name)
|
182
|
+
|
183
|
+
|
184
|
+
def _get_foreign_path() -> Path:
|
185
|
+
"""Find the path to the library that called this package.
|
186
|
+
|
187
|
+
Search the call stack for the first source code file outside of configaroo.
|
188
|
+
"""
|
189
|
+
self_prefix = Path(__file__).parent.parent
|
190
|
+
return next(
|
191
|
+
path
|
192
|
+
for frame in inspect.stack()
|
193
|
+
if not (path := Path(frame.filename)).is_relative_to(self_prefix)
|
194
|
+
)
|
195
|
+
|
196
|
+
|
197
|
+
def _incomplete_format(text: str, replacers: dict[str, Any]) -> str:
|
198
|
+
"""Replace some, but not necessarily all format specifiers in a text string.
|
199
|
+
|
200
|
+
Regular .format() raises an error if not all {replace} parameters are
|
201
|
+
supplied. Here, we only replace the given replace arguments and leave the
|
202
|
+
rest untouched.
|
203
|
+
"""
|
204
|
+
dot = "__DOT__" # Escape . in fields as they have special meaning in .format()
|
205
|
+
pattern = r"({{{word}(?:![ars])?(?:|:[^}}]*)}})" # Match {word} or {word:...}
|
206
|
+
|
207
|
+
for word, replacement in replacers.items():
|
208
|
+
for match in re.findall(pattern.format(word=word), text):
|
209
|
+
# Split expression to only replace . in the field name
|
210
|
+
field, colon, fmt = match.partition(":")
|
211
|
+
replacer = f"{field.replace('.', dot)}{colon}{fmt}".format(
|
212
|
+
**{word.replace(".", dot): replacement}
|
213
|
+
)
|
214
|
+
text = text.replace(match, replacer)
|
215
|
+
return text
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: configaroo
|
3
|
+
Version: 0.1.2
|
4
|
+
Summary: Bouncy handling of configuration files
|
5
|
+
Author-email: Geir Arne Hjelle <geirarne@gmail.com>
|
6
|
+
Maintainer-email: Geir Arne Hjelle <geirarne@gmail.com>
|
7
|
+
License-Expression: MIT
|
8
|
+
Project-URL: homepage, https://github.com/gahjelle/configaroo
|
9
|
+
Project-URL: github, https://github.com/gahjelle/configaroo
|
10
|
+
Project-URL: issues, https://github.com/gahjelle/configaroo/issues
|
11
|
+
Project-URL: changelog, https://github.com/gahjelle/configaroo/blob/main/CHANGELOG.md
|
12
|
+
Keywords: configuration,configuration-management,toml,json
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
14
|
+
Classifier: Intended Audience :: Developers
|
15
|
+
Classifier: Natural Language :: English
|
16
|
+
Classifier: Operating System :: OS Independent
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Classifier: Typing :: Typed
|
24
|
+
Requires-Python: >=3.11
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
License-File: LICENSE
|
27
|
+
Requires-Dist: pydantic>=2.0
|
28
|
+
Requires-Dist: pyplugs>=0.4.0
|
29
|
+
Dynamic: license-file
|
30
|
+
|
31
|
+
# Configaroo - Bouncy Configuration Handling
|
32
|
+
|
33
|
+
Configaroo is a light configuration package for Python that offers the following features:
|
34
|
+
|
35
|
+
- Access configuration settings with dotted keys: `config.nested.key`
|
36
|
+
- Use different configuration file formats, including TOML and JSON
|
37
|
+
- Override key configuration settings with environment variables
|
38
|
+
- Validate a configuration based on a Pydantic model
|
39
|
+
- Convert the type of configuration values based on a Pydantic model
|
40
|
+
- Dynamically format certain configuration values
|
@@ -1,8 +1,16 @@
|
|
1
1
|
"""Test base Configuration functionality"""
|
2
2
|
|
3
|
+
from pathlib import Path
|
4
|
+
|
3
5
|
import pytest
|
4
6
|
|
5
|
-
from configaroo import Configuration
|
7
|
+
from configaroo import Configuration, configuration
|
8
|
+
|
9
|
+
|
10
|
+
@pytest.fixture
|
11
|
+
def file_path():
|
12
|
+
"""The path to the current file"""
|
13
|
+
return Path(__file__).resolve()
|
6
14
|
|
7
15
|
|
8
16
|
def test_read_simple_values_as_attributes(config):
|
@@ -93,18 +101,68 @@ def test_contains_with_dotted_key(config):
|
|
93
101
|
assert "nested.number" not in config
|
94
102
|
|
95
103
|
|
96
|
-
def test_parse_dynamic_default(config):
|
104
|
+
def test_parse_dynamic_default(config, file_path):
|
97
105
|
"""Test parsing of default dynamic variables"""
|
98
|
-
parsed_config = config.parse_dynamic()
|
99
|
-
|
106
|
+
parsed_config = (config | {"diameter": "2 x {nested.pie}"}).parse_dynamic()
|
107
|
+
print("pyproject.toml dir: ", configuration._find_pyproject_toml(file_path))
|
108
|
+
print(f"{parsed_config.paths.dynamic = }")
|
109
|
+
assert parsed_config.paths.dynamic == str(file_path)
|
100
110
|
assert parsed_config.phrase == "The meaning of life is 42"
|
111
|
+
assert parsed_config.diameter == "2 x 3.14"
|
101
112
|
|
102
113
|
|
103
|
-
def test_parse_dynamic_extra(config):
|
114
|
+
def test_parse_dynamic_extra(config, file_path):
|
104
115
|
"""Test parsing of extra dynamic variables"""
|
105
|
-
parsed_config = (config | {"animal": "{adjective}
|
106
|
-
extra={"number": 14, "adjective": "
|
116
|
+
parsed_config = (config | {"animal": "{adjective} kangaroo"}).parse_dynamic(
|
117
|
+
extra={"number": 14, "adjective": "bouncy"}
|
107
118
|
)
|
108
|
-
assert parsed_config.paths.dynamic ==
|
119
|
+
assert parsed_config.paths.dynamic == str(file_path)
|
109
120
|
assert parsed_config.phrase == "The meaning of life is 14"
|
110
|
-
assert parsed_config.animal == "
|
121
|
+
assert parsed_config.animal == "bouncy kangaroo"
|
122
|
+
|
123
|
+
|
124
|
+
def test_parse_dynamic_formatted(config):
|
125
|
+
"""Test that formatting works for dynamic variables"""
|
126
|
+
parsed_config = (
|
127
|
+
config
|
128
|
+
| {
|
129
|
+
"string": "Hey {word!r}",
|
130
|
+
"three": "->{nested.pie:6.0f}<-",
|
131
|
+
"centered": "|{word:^12}|",
|
132
|
+
}
|
133
|
+
).parse_dynamic()
|
134
|
+
assert parsed_config.centered == "| platypus |"
|
135
|
+
assert parsed_config.three == "-> 3<-"
|
136
|
+
assert parsed_config.string == "Hey 'platypus'"
|
137
|
+
|
138
|
+
|
139
|
+
def test_parse_dynamic_ignore(config):
|
140
|
+
"""Test that parsing of dynamic variables ignores unknown replacements"""
|
141
|
+
parsed_config = (
|
142
|
+
config
|
143
|
+
| {
|
144
|
+
"animal": "{adjective} kangaroo",
|
145
|
+
"phrase": "one {nested.non_existent} dollar",
|
146
|
+
}
|
147
|
+
).parse_dynamic()
|
148
|
+
assert parsed_config.animal == "{adjective} kangaroo"
|
149
|
+
assert parsed_config.phrase == "one {nested.non_existent} dollar"
|
150
|
+
|
151
|
+
|
152
|
+
def test_find_pyproject_toml():
|
153
|
+
"""Test that the pyproject.toml file can be located"""
|
154
|
+
assert configuration._find_pyproject_toml() == Path(__file__).parent.parent
|
155
|
+
|
156
|
+
|
157
|
+
def test_find_foreign_caller():
|
158
|
+
"""Test that a foreign caller (outside of configaroo) can be identified"""
|
159
|
+
assert configuration._get_foreign_path() == Path(__file__)
|
160
|
+
|
161
|
+
|
162
|
+
def test_incomplete_formatter():
|
163
|
+
"""Test that the incomplete formatter can handle fields that aren't replaced"""
|
164
|
+
formatted = configuration._incomplete_format(
|
165
|
+
"{number:5.1f} {non_existent} {string!r} {name}",
|
166
|
+
{"number": 3.14, "string": "platypus", "name": "Geir Arne"},
|
167
|
+
)
|
168
|
+
assert formatted == " 3.1 {non_existent} 'platypus' Geir Arne"
|
configaroo-0.1.0/PKG-INFO
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: configaroo
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: Bouncy handling of configuration files
|
5
|
-
Author-email: Geir Arne Hjelle <geirarne@gmail.com>
|
6
|
-
Requires-Python: >=3.11
|
7
|
-
Description-Content-Type: text/markdown
|
8
|
-
Requires-Dist: pydantic>=2.0
|
9
|
-
Requires-Dist: pyplugs>=0.4.0
|
10
|
-
Requires-Dist: python-dotenv>=1.1.0
|
11
|
-
|
12
|
-
# Configaroo - Bouncy Configuration Handling
|
13
|
-
|
14
|
-
Configaroo is a light configuration package for Python that offers the following features:
|
15
|
-
|
16
|
-
- Access configuration settings with dotted keys: `config.nested.key`
|
17
|
-
- Use different configuration file formats, including TOML and JSON
|
18
|
-
- Override key configuration settings with environment variables
|
19
|
-
- Validate a configuration based on a Pydantic model
|
20
|
-
- Convert the type of configuration values based on a Pydantic model
|
21
|
-
- Dynamically format certain configuration values
|
configaroo-0.1.0/pyproject.toml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
[project]
|
2
|
-
name = "configaroo"
|
3
|
-
version = "0.1.0"
|
4
|
-
description = "Bouncy handling of configuration files"
|
5
|
-
readme = "README.md"
|
6
|
-
authors = [{ name = "Geir Arne Hjelle", email = "geirarne@gmail.com" }]
|
7
|
-
requires-python = ">=3.11"
|
8
|
-
dependencies = ["pydantic>=2.0", "pyplugs>=0.4.0", "python-dotenv>=1.1.0"]
|
9
|
-
|
10
|
-
[build-system]
|
11
|
-
requires = ["setuptools>=61"]
|
12
|
-
build-backend = "setuptools.build_meta"
|
13
|
-
|
14
|
-
[dependency-groups]
|
15
|
-
dev = ["ipython>=8.36.0", "pytest>=8.3.5", "ruff>=0.11.11", "tomli-w>=1.2.0"]
|
@@ -1,21 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: configaroo
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: Bouncy handling of configuration files
|
5
|
-
Author-email: Geir Arne Hjelle <geirarne@gmail.com>
|
6
|
-
Requires-Python: >=3.11
|
7
|
-
Description-Content-Type: text/markdown
|
8
|
-
Requires-Dist: pydantic>=2.0
|
9
|
-
Requires-Dist: pyplugs>=0.4.0
|
10
|
-
Requires-Dist: python-dotenv>=1.1.0
|
11
|
-
|
12
|
-
# Configaroo - Bouncy Configuration Handling
|
13
|
-
|
14
|
-
Configaroo is a light configuration package for Python that offers the following features:
|
15
|
-
|
16
|
-
- Access configuration settings with dotted keys: `config.nested.key`
|
17
|
-
- Use different configuration file formats, including TOML and JSON
|
18
|
-
- Override key configuration settings with environment variables
|
19
|
-
- Validate a configuration based on a Pydantic model
|
20
|
-
- Convert the type of configuration values based on a Pydantic model
|
21
|
-
- Dynamically format certain configuration values
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|