confygure: A simple YAML based configuration library for Python
Install
❯ pip install confygure
Usage
The library loads a config.yml from the current directory by default.
Given the config.yml:
test: some value
You can use confygure like this:
>>> from confygure import config
>>> config('test')
'some value'
If you want typing, you can get typed results like this:
>>> from confygure import config_t, config_rt
>>> config_t(str, 'test') # config_t ensures the return value is a str
'some value'
>>> config_t(str, 'nonexist') # config_t allows empty values
None
>>> config_rt(str, 'nonexist') # config_rt requires a value
KeyError: "Missing configuration key ('nonexist',)"
In short, you can access configuration using the following methods:
config(...): Anyconfig_t(T, ...): T | Noneconfig_rt(T, ...): T
You can use the setup() method to specify the location of the configuration
file and if the log level of the root logger should be configured:
Given the configuration file example.yml:
test: some value
logger:
loglevel: DEBUG
To load this custom configuration file and set the location of the log level config, use something like this:
>>> from confygure import setup, config
>>> setup(files=['./example.yml', '~/example.yml'],
... logger=['logger', 'loglevel'])
>>> config()
INFO:root:Updated configuration from ./example01.yml
INFO:root:Log level set to DEBUG
{'test': 'some value', 'logger': {'loglevel': 'DEBUG'}}
This will actually check if a local file ./example.yml exists and fall back
to ~/example.yml from your home directory.
Metadata
Release files for confygure 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| confygure-0.1.0.tar.gz | 4.0 kB | Without provenance | Details |
Release files / confygure-0.1.0.tar.gz
| Download URL | confygure-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b351bde07264e9cab198e250c7d28cf3e9a49a5381bc9b8c32bbdd2dfaa1ef4e
|
|
BLAKE2b-256 checksum How to use checksums |
98c090c6e56307348f46795fecc0ce54af00af1faf4879b4352950fdcd7209ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.7
|
Security for confygure 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.