Easy Yaml based Configuration for Python
Project description
EYConf
Easy Yaml based Configuration for Python
Features
- Generate: Automatically convert a schema to a yaml configuration file, including comments!
- Validate: Validate a given configuration file against your schema and raise human readable errors!
- Extend: Introduce custom logic by extending the
EYConfclass! - Reload: Reload your configuration on the fly without restarting your application!
Installation
You can install EYConf from PyPI using pip.
pip install eyconf
Quickstart
First of define a configuration schema using dataclasses.
from dataclasses import dataclass
from typing import Optional
@dataclass
class Transport:
"""Email transport configuration"""
host: str = 'imap.example.com'
port: int = 993
username: str = 'user'
password: str = 'password'
use_ssl: bool = False
@dataclass
class Other:
"""Other configuration options"""
bar: Optional[int]
@dataclass
class ConfigSchema:
"""My configuration schema
Docstrings are used as comments in the generated yaml file!
"""
transport: Transport
other: Other
We can now create a configuration using the EYConf class directly, if you need
more control it is also possible to extend the class.
# Using create_config_class helper function
from eyconf import EYConf
config = EYConf(ConfigSchema,'config.yaml')
This created the config.yaml file in your current working directory with the following content. Notice that the
docstrings are used as comments in the generated yaml file.
# My configuration schema
# Docstrings are used as comments in the generated yaml file!
transport:
# Email transport configuration
host: imap.example.com
port: 993
username: user
password: password
use_ssl: false
other:
# Other configuration options
bar: null
You can access your configuration directly as attributes of the config object.
assert type(config.transport) == Transport
assert config.transport.host == "imap.example.com"
If you want to change the configuration, you can do so by editing the config.yaml file directly and reloading the configuration.
...
transport:
host: changed.example.com
config.refresh()
assert config.transport.host == "changed.example.com"
For more information, please refer to the documentation.
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 eyconf-0.0.5.tar.gz.
File metadata
- Download URL: eyconf-0.0.5.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efd6e89baaf7211629d9342012c98dc24fa72a2dbe0e84cb508df2bc5a5eca84
|
|
| MD5 |
e57eb55a6a6e4dda6701645bffbe70a1
|
|
| BLAKE2b-256 |
2c400b9a33b8f379ae5d647db76f8ccbbe563a9c4be645f4a99ba30ea978ed76
|
Provenance
The following attestation bundles were made for eyconf-0.0.5.tar.gz:
Publisher:
publish.yml on semohr/eyconf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eyconf-0.0.5.tar.gz -
Subject digest:
efd6e89baaf7211629d9342012c98dc24fa72a2dbe0e84cb508df2bc5a5eca84 - Sigstore transparency entry: 167220359
- Sigstore integration time:
-
Permalink:
semohr/eyconf@0df2d2a8e1972c6a8cb956b95714585648f5b6eb -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/semohr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0df2d2a8e1972c6a8cb956b95714585648f5b6eb -
Trigger Event:
release
-
Statement type:
File details
Details for the file eyconf-0.0.5-py3-none-any.whl.
File metadata
- Download URL: eyconf-0.0.5-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e942af7f68ec0e3e75fe3a7781428dcb0e421fbcdb73f3937f671fa3deb92c61
|
|
| MD5 |
7165d6230d80cef23d726d6b63d01ccc
|
|
| BLAKE2b-256 |
9d7beb2dbac71e71f81705e4b0fe6e96bac5dde5857be4c17a19c28ce2a10c5f
|
Provenance
The following attestation bundles were made for eyconf-0.0.5-py3-none-any.whl:
Publisher:
publish.yml on semohr/eyconf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eyconf-0.0.5-py3-none-any.whl -
Subject digest:
e942af7f68ec0e3e75fe3a7781428dcb0e421fbcdb73f3937f671fa3deb92c61 - Sigstore transparency entry: 167220361
- Sigstore integration time:
-
Permalink:
semohr/eyconf@0df2d2a8e1972c6a8cb956b95714585648f5b6eb -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/semohr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0df2d2a8e1972c6a8cb956b95714585648f5b6eb -
Trigger Event:
release
-
Statement type: