typed 12-factor app configuration helper
Project description
basecfg
basecfg is a Python library designed to simplify and standardize the process of configuring a Python application, particularly a Dockerized application.
Users of this library create a class which inherits from basecfg.BaseCfg. For each configuration option an app should support, a type-annotated class attribute is defined using a call to opt.
Once a config class is instantiated it automatically populates the configuration from these sources:
- default values declared in the configuration class
- a JSON config file (such as a Kubernetes ConfigMap)
- a
.envfile (indocker runenvfile format) - environment variables
- docker secrets
- command-line arguments
Example
This file is an excerpt from a more extensive example implementation of the library:
#!/usr/bin/env python3
from typing import Optional
from basecfg import BaseCfg, opt
class ExampleAppConf(BaseCfg):
server_username: str = opt(
default="demoperson",
doc="The username to use on the server",
)
server_password: Optional[str] = opt(
default=None,
doc="The password to use on the server",
redact=True,
)
verbose: bool = opt(
default=False,
doc="whether to log verbosely",
)
batch_size: Optional[int] = opt(
default=None,
doc="how many objects to transfer at a time",
)
Project details
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 basecfg-2.1.1.tar.gz.
File metadata
- Download URL: basecfg-2.1.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ed6ec0782f5fba01c4bb9b1c4263761eb65bda08d9de3f3a1872cf569054602
|
|
| MD5 |
0e63234e28a1b810461ba1ba4ac3ec56
|
|
| BLAKE2b-256 |
a341098fa27b06c17cb6ccacaf26bde98b657e8495171db49951ddb412714e9a
|
File details
Details for the file basecfg-2.1.1-py3-none-any.whl.
File metadata
- Download URL: basecfg-2.1.1-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
696a1a9823ff37862c4b00834f6dcc58b2e42b1157c22205aae8b9c7de0190f5
|
|
| MD5 |
0eb585d332a1305f20e67e9eae70ff9e
|
|
| BLAKE2b-256 |
4cea1b6dc6b769574e197b533223d9ae0cac35b2e30d8da20d201bc521c3fd2f
|