Easy app configuration.
Project description
praline-config
Python app configuration library to instantiate Python objects from various configuration inputs.
Purpose
praline-config
endeavours to make gathering configuration inputs from various
sources as low-friction and straightforward as possible.
Getting Started
Installation
pip install praline-config
Example Usage
Using praline.config
has a few steps...
- Write configuration data in a supported format(yaml, toml, dotenv, etc..)
- Define a dataclass to hold your configuration data
- Instantiate the configuration object
Example YAML Configuration
server_address: "www.example.com"
threads: 4
Example Program
#!/usr/bin/env python3
from dataclasses import dataclass
from praline.config import AppConfigBase
@dataclass
class AppConfig(AppConfigBase):
server_address: str = None
threads: int = None
def main():
app_config: AppConfig = AppConfig.load(config="example.yaml")
print(f"Server: {app_config.server_address}")
print(f"Threads: {app_config.threads}")
if __name__ == "__main__":
exit(main())
Output
Server: www.example.com
Threads: 4
Supported Configuration Sources
praline-config
leverages the python-configuration
package to handle the raw
configuration data, so any format it supports is supported. Additionally,
praline-config
can handle importing dotenv
formatted files and binding
environment variable values to fields in your configuration class. Finally, it
can also incorporate values gathered from the CLI or similar through an
dictionary.
See the documentation for python-configuration for the complete list of supported formats.
Dependencies
python-configuration
A library to load configuration parameters hierarchically from multiple sources and formats
python-configuration
is an excellent library designed to interface with many
different sources commonly used to store configuration data. We use it here as
an adaptor for the various configuration sources being used as inputs.
python-dotenv
Python-dotenv reads key-value pairs from a .env file and can set them as environment variables. It helps in the development of applications following the 12-factor principles.
Used to load .env
formatted files.
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
File details
Details for the file praline_config-0.1.0.tar.gz
.
File metadata
- Download URL: praline_config-0.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d347e367486797c6fbaebcf7316cbf89e9316211f64fef556161ff56182a2118 |
|
MD5 | 3bb3ebd21434df6fdca632e7dcf4b8af |
|
BLAKE2b-256 | fcf06654ce2214b9dfebb43fb8af1d546658ea76e2710c1790adbd8b70320c99 |
File details
Details for the file praline_config-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: praline_config-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c35e4ed086ddbfdd2232ddda8d9c58eff21212491c8d528354994af2b2edc9 |
|
MD5 | a6418ab4eed84ecd5d0ba840f124dad0 |
|
BLAKE2b-256 | fefc3eaf34e63d75ed4ee446afe1e27f1827c5f9dedf789c65a42e1fa0471ca2 |