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",
)
Metadata
Release files for basecfg 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| basecfg-2.1.1.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| basecfg-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.5 kB
Release files / basecfg-2.1.1.tar.gz
| Download URL | basecfg-2.1.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ed6ec0782f5fba01c4bb9b1c4263761eb65bda08d9de3f3a1872cf569054602
|
|
BLAKE2b-256 checksum How to use checksums |
a341098fa27b06c17cb6ccacaf26bde98b657e8495171db49951ddb412714e9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / basecfg-2.1.1-py3-none-any.whl
| Download URL | basecfg-2.1.1-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
696a1a9823ff37862c4b00834f6dcc58b2e42b1157c22205aae8b9c7de0190f5
|
|
BLAKE2b-256 checksum How to use checksums |
4cea1b6dc6b769574e197b533223d9ae0cac35b2e30d8da20d201bc521c3fd2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|