Provide an auto-discovery process for configurations
Project description
Mission
Provide an auto-discovery process of configurations for simple code use. Given a path and a list of pattern, the result config will be a shortcut to any config.
Usage
Setup:
config = mixin(
path="path/to/my/files",
patterns=["path/(*)/file.yaml"]
)
Use it:
print config.mynamespace.key
Parameters
-
path
Initial path to configs. Patterns will be tested against the file structure underneath the path, and it will be ignored in determining the namespacing.
-
patterns
A list of file paths containing (or not) placeholders "(*)" o find where the configuration files are located. The patterns definition order defines which keys has the priority, the last one being the most relevant.
Each placeholder in the path will result in a namespace in the resulting config. So let's say you have a pattern
dir1/(*)/dir2/(*).yamlIf this pattern finds the file : "dir1/ns1/dir2/file.yaml" that contains "key: 'value'", the resulting config will be
config.ns1.file.key == "value"now if the pattern was
dir1/ns1/dir2/file.yamlfor the same file, the resulting config would simply be
config.key == "value"so you can use placeholders "(*)" to namespace the resulting config and use "*" without the parenthesis to have a variable path without the namespacing
dir1/(*)/dir2/*.yaml config.ns1.key == "value"
Mocking the probing
Your unit test can have your code use fake_probe instead to which to give a dict, and it will appear as if it was just mixed-in. Example:
config = fake_probe({
"ns1": {
"file": {
"key": "value"
}
}
})
# then
config.ns1.file.key == "value"
Contributing
Feel free to raise issues and send some pull request, we'll be happy to look at them!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file config_mixin-1.0.1.tar.gz.
File metadata
- Download URL: config_mixin-1.0.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c028c74041350b783b2ddaa41c2d11e352ffd91c50fea700d6eb776c0a29ff
|
|
| MD5 |
1eeee02036e895baf4e4d888bf0f1938
|
|
| BLAKE2b-256 |
b71020a8a2180bb862d24f5f9de2957b144702a5770a33e1253838202be800ea
|
Provenance
The following attestation bundles were made for config_mixin-1.0.1.tar.gz:
Publisher:
publish.yml on stephanerobert/config-mixin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
config_mixin-1.0.1.tar.gz -
Subject digest:
b1c028c74041350b783b2ddaa41c2d11e352ffd91c50fea700d6eb776c0a29ff - Sigstore transparency entry: 838704345
- Sigstore integration time:
-
Permalink:
stephanerobert/config-mixin@b9d34ff8afaf384be7fdee07f5e0c0483268c384 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/stephanerobert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b9d34ff8afaf384be7fdee07f5e0c0483268c384 -
Trigger Event:
release
-
Statement type:
File details
Details for the file config_mixin-1.0.1-py3-none-any.whl.
File metadata
- Download URL: config_mixin-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c4b0b4950768764e1e147dbca2b688994f097ad74b76471db3ab88ae2365fac
|
|
| MD5 |
1a981b55a06a7c5555f42f539f10155d
|
|
| BLAKE2b-256 |
da913b7dd642bd83dbf7b56fa261ffee9c69eb22f8b6ef86ae0508a44ce9377e
|
Provenance
The following attestation bundles were made for config_mixin-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on stephanerobert/config-mixin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
config_mixin-1.0.1-py3-none-any.whl -
Subject digest:
5c4b0b4950768764e1e147dbca2b688994f097ad74b76471db3ab88ae2365fac - Sigstore transparency entry: 838704349
- Sigstore integration time:
-
Permalink:
stephanerobert/config-mixin@b9d34ff8afaf384be7fdee07f5e0c0483268c384 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/stephanerobert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b9d34ff8afaf384be7fdee07f5e0c0483268c384 -
Trigger Event:
release
-
Statement type: