appsettings2 2.1.1__tar.gz → 2.1.4__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.
- {appsettings2-2.1.1/src/appsettings2.egg-info → appsettings2-2.1.4}/PKG-INFO +3 -7
- {appsettings2-2.1.1 → appsettings2-2.1.4}/pyproject.toml +6 -26
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/Configuration.py +17 -1
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/ConfigurationBuilder.py +1 -1
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/SKILL.md +4 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/__init__.py +2 -2
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/helpers.py +1 -1
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/EnvironmentConfigurationProvider.py +7 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4/src/appsettings2.egg-info}/PKG-INFO +3 -7
- appsettings2-2.1.4/src/appsettings2.egg-info/requires.txt +7 -0
- appsettings2-2.1.1/src/appsettings2.egg-info/requires.txt +0 -11
- {appsettings2-2.1.1 → appsettings2-2.1.4}/LICENSE +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/README.md +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/setup.cfg +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/ConfigurationException.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/ConfigurationWatcher.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/CommandLineConfigurationProvider.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/ConfigurationProvider.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/JsonConfigurationProvider.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/TomlConfigurationProvider.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/YamlConfigurationProvider.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/__init__.py +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/py.typed +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2.egg-info/SOURCES.txt +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2.egg-info/dependency_links.txt +0 -0
- {appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: appsettings2
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: ..unify configuration sources into a `Configuration` object that can be bound to complex types, or accessed directly for configuration data.
|
|
5
5
|
Author-email: Shaun Wilson <mrshaunwilson@msn.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Documentation, https://appsettings2.readthedocs.io/
|
|
@@ -17,12 +17,8 @@ License-File: LICENSE
|
|
|
17
17
|
Requires-Dist: pyyaml>=6.0.3
|
|
18
18
|
Provides-Extra: dev
|
|
19
19
|
Requires-Dist: coverage; extra == "dev"
|
|
20
|
-
Requires-Dist: flake8; extra == "dev"
|
|
21
|
-
Requires-Dist: flake8-pyproject; extra == "dev"
|
|
22
20
|
Requires-Dist: mypy; extra == "dev"
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: punit>=1.12.5; extra == "dev"
|
|
25
|
-
Requires-Dist: twine; extra == "dev"
|
|
21
|
+
Requires-Dist: punit>=1.14.2; extra == "dev"
|
|
26
22
|
Requires-Dist: types-PyYAML; extra == "dev"
|
|
27
23
|
Dynamic: license-file
|
|
28
24
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "appsettings2"
|
|
3
|
-
version = "2.1.
|
|
4
|
-
description = "
|
|
3
|
+
version = "2.1.4"
|
|
4
|
+
description = "..unify configuration sources into a `Configuration` object that can be bound to complex types, or accessed directly for configuration data."
|
|
5
5
|
keywords = ["appsettings", "configuration"]
|
|
6
6
|
authors = [
|
|
7
7
|
{ name="Shaun Wilson", email="mrshaunwilson@msn.com" }
|
|
@@ -15,18 +15,14 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
requires-python = ">=3.11"
|
|
17
17
|
dependencies = [
|
|
18
|
-
"pyyaml>=6.0.3"
|
|
18
|
+
"pyyaml (>=6.0.3)"
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
[project.optional-dependencies]
|
|
22
22
|
dev = [
|
|
23
23
|
"coverage",
|
|
24
|
-
"flake8",
|
|
25
|
-
"flake8-pyproject",
|
|
26
24
|
"mypy",
|
|
27
|
-
"
|
|
28
|
-
"punit (>=1.12.5)",
|
|
29
|
-
"twine",
|
|
25
|
+
"punit (>=1.14.2)",
|
|
30
26
|
"types-PyYAML"
|
|
31
27
|
]
|
|
32
28
|
|
|
@@ -35,24 +31,8 @@ Documentation = "https://appsettings2.readthedocs.io/"
|
|
|
35
31
|
Homepage = "https://github.com/wilson0x4d/appsettings2"
|
|
36
32
|
Repository = "https://github.com/wilson0x4d/appsettings2.git"
|
|
37
33
|
|
|
38
|
-
[build-system]
|
|
39
|
-
requires = ["setuptools"]
|
|
40
|
-
build-backend = "setuptools.build_meta"
|
|
41
|
-
|
|
42
|
-
[tool.setuptools.packages.find]
|
|
43
|
-
where = ["src"]
|
|
44
|
-
exclude = [
|
|
45
|
-
"docs",
|
|
46
|
-
"tests",
|
|
47
|
-
"tests.*"
|
|
48
|
-
]
|
|
49
|
-
|
|
50
34
|
[tool.setuptools.package-data]
|
|
51
35
|
"appsettings2" = ["py.typed", "SKILL.md"]
|
|
52
36
|
|
|
53
|
-
[tool.
|
|
54
|
-
|
|
55
|
-
ignore = ["D100","E501"]
|
|
56
|
-
per-file-ignores = [
|
|
57
|
-
"tests/*.py:D012,E306",
|
|
58
|
-
]
|
|
37
|
+
[tool.uv]
|
|
38
|
+
package = true
|
|
@@ -585,8 +585,13 @@ class Configuration:
|
|
|
585
585
|
"""
|
|
586
586
|
Set the configuration value for a configuration key.
|
|
587
587
|
|
|
588
|
-
:param key: The *key* to associate the configuration *value*.
|
|
588
|
+
:param key: The *key* to associate the configuration *value*. Supports `__` and `:` hierarchical delimiters.
|
|
589
589
|
:param value: The *value* to be associated with the configuration *key*.
|
|
590
|
+
|
|
591
|
+
Intermediate segments of a hierarchical key are created as nested
|
|
592
|
+
:py:class:`~appsettings2.Configuration` objects as needed. If an
|
|
593
|
+
intermediate segment already holds a non-``Configuration`` value
|
|
594
|
+
(e.g. a scalar or list), it is replaced by a new ``Configuration``.
|
|
590
595
|
"""
|
|
591
596
|
if self.__normalize:
|
|
592
597
|
key = key.upper()
|
|
@@ -608,6 +613,12 @@ class Configuration:
|
|
|
608
613
|
o = c
|
|
609
614
|
else:
|
|
610
615
|
o = getattr(self, self.__scrub_key(k))
|
|
616
|
+
if not isinstance(o, Configuration):
|
|
617
|
+
c = Configuration(normalize=self.__normalize, scrubkeys=(
|
|
618
|
+
self.__key_scrub_re is None))
|
|
619
|
+
setattr(self, self.__scrub_key(k), c)
|
|
620
|
+
self.__add_child_change_handler(parts[i])
|
|
621
|
+
o = c
|
|
611
622
|
else:
|
|
612
623
|
if not o.has_key(parts[i]):
|
|
613
624
|
c = Configuration(normalize=self.__normalize, scrubkeys=(
|
|
@@ -616,6 +627,11 @@ class Configuration:
|
|
|
616
627
|
o = c
|
|
617
628
|
else:
|
|
618
629
|
o = o.get(parts[i])
|
|
630
|
+
if not isinstance(o, Configuration):
|
|
631
|
+
c = Configuration(normalize=self.__normalize, scrubkeys=(
|
|
632
|
+
self.__key_scrub_re is None))
|
|
633
|
+
o.set(parts[i], c)
|
|
634
|
+
o = c
|
|
619
635
|
|
|
620
636
|
# Convert dict/list values
|
|
621
637
|
vtype = type(value)
|
|
@@ -76,7 +76,7 @@ class ConfigurationBuilder:
|
|
|
76
76
|
"""
|
|
77
77
|
Add a :py:class:`~appsettings2.providers.EnvironmentConfigurationProvider`.
|
|
78
78
|
|
|
79
|
-
:param required_prefix: Optional prefix used to filter which environment variables are included. Only variables whose names start with this prefix (followed by ``_`` or ``__``) will be loaded. When ``None``, all environment variables are included. Defaults to None.
|
|
79
|
+
:param required_prefix: Optional prefix used to filter which environment variables are included. Only variables whose names start with this prefix (followed by ``_`` or ``__``) will be loaded. When ``None``, all environment variables are included. Defaults to None. Note that environment variables whose names begin with an underscore are unsupported and are always ignored, even when ``required_prefix`` matches them.
|
|
80
80
|
:return: Returns :py:class:`~appsettings2.ConfigurationBuilder` for method chaining.
|
|
81
81
|
"""
|
|
82
82
|
return self.add_provider(EnvironmentConfigurationProvider(required_prefix=required_prefix))
|
|
@@ -82,6 +82,8 @@ export MYAPP_DB_HOST=postgres://... # loaded as "DB_HOST"
|
|
|
82
82
|
export OTHER_KEY=value # ignored
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
Env vars whose names begin with an underscore (e.g. `_FOO`, `__FOO`) are unsupported and are always ignored, even when `required_prefix` is set to a matching value. This prevents double-underscore-prefixed variables from producing an unwanted empty (`''`) hierarchy key.
|
|
86
|
+
|
|
85
87
|
### `build()`
|
|
86
88
|
|
|
87
89
|
```python
|
|
@@ -122,6 +124,8 @@ config.set('Section__Key', 'value') # hierarchical key
|
|
|
122
124
|
config['Section__Key'] = 'value' # same via setter
|
|
123
125
|
```
|
|
124
126
|
|
|
127
|
+
Intermediate segments are created as nested `Configuration` objects as needed; if an intermediate segment already holds a non-`Configuration` value (scalar/list), it is replaced by a new `Configuration`.
|
|
128
|
+
|
|
125
129
|
### Other members
|
|
126
130
|
|
|
127
131
|
| Member | Signature | Description |
|
|
@@ -30,7 +30,7 @@ def get_configuration(
|
|
|
30
30
|
:param cli: ``True`` to load configuration from Command-Line, defaults to True
|
|
31
31
|
:param environment: ``True`` to load configuration from process Environment, defaults to True
|
|
32
32
|
:param variations: A set of variations to apply to use with file-based Configuration Providers, defaults to ['', 'prod', 'production', 'stage', 'staging', 'qa', 'dev', 'development', 'local']
|
|
33
|
-
:param env_prefix: (OPTIONAL) When specified, only env vars having the specified prefix are bound as configuration settings, the prefix is stripped from the resulting setting name.
|
|
33
|
+
:param env_prefix: (OPTIONAL) When specified, only env vars having the specified prefix are bound as configuration settings, the prefix is stripped from the resulting setting name. Env vars whose names begin with an underscore are unsupported and are always ignored, even when they match ``env_prefix``.
|
|
34
34
|
:param disable_events: Option indicating whether change events should be emitted, defaults to False.
|
|
35
35
|
:return: An ``appsettings2.Configuration`` instance.
|
|
36
36
|
"""
|
|
@@ -33,8 +33,15 @@ class EnvironmentConfigurationProvider(ConfigurationProvider):
|
|
|
33
33
|
|
|
34
34
|
When ``required_prefix`` is set, only keys starting with that prefix are included,
|
|
35
35
|
and the prefix is stripped from each key in the output configuration.
|
|
36
|
+
|
|
37
|
+
Environment variable names starting with an underscore (e.g. ``_FOO``,
|
|
38
|
+
``__FOO``) are unsupported and are always ignored, even when they match
|
|
39
|
+
``required_prefix``. This prevents double-underscore-prefixed variables
|
|
40
|
+
from producing empty (``''``) hierarchy keys.
|
|
36
41
|
"""
|
|
37
42
|
for k in os.environ:
|
|
43
|
+
if k.startswith('_'):
|
|
44
|
+
continue
|
|
38
45
|
key = (
|
|
39
46
|
k
|
|
40
47
|
if self.__required_prefix is None
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: appsettings2
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: ..unify configuration sources into a `Configuration` object that can be bound to complex types, or accessed directly for configuration data.
|
|
5
5
|
Author-email: Shaun Wilson <mrshaunwilson@msn.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Documentation, https://appsettings2.readthedocs.io/
|
|
@@ -17,12 +17,8 @@ License-File: LICENSE
|
|
|
17
17
|
Requires-Dist: pyyaml>=6.0.3
|
|
18
18
|
Provides-Extra: dev
|
|
19
19
|
Requires-Dist: coverage; extra == "dev"
|
|
20
|
-
Requires-Dist: flake8; extra == "dev"
|
|
21
|
-
Requires-Dist: flake8-pyproject; extra == "dev"
|
|
22
20
|
Requires-Dist: mypy; extra == "dev"
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: punit>=1.12.5; extra == "dev"
|
|
25
|
-
Requires-Dist: twine; extra == "dev"
|
|
21
|
+
Requires-Dist: punit>=1.14.2; extra == "dev"
|
|
26
22
|
Requires-Dist: types-PyYAML; extra == "dev"
|
|
27
23
|
Dynamic: license-file
|
|
28
24
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/ConfigurationProvider.py
RENAMED
|
File without changes
|
{appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/JsonConfigurationProvider.py
RENAMED
|
File without changes
|
{appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/TomlConfigurationProvider.py
RENAMED
|
File without changes
|
{appsettings2-2.1.1 → appsettings2-2.1.4}/src/appsettings2/providers/YamlConfigurationProvider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|