Configuration Manager
Project description
dwgriffin-config
dwgriffin's config library.
Installation
python3 -m pip install dwgriffin-config
Classes
ConfigManager
Takes a dictionary of default settings. Merges configuration settings from defaults, config file, environment variables, and CLI arguments.
Usage
import argparse
import os
from dwgriffin_config import ConfigManager
parser = argparse.ArgumentParser(description="An example CLI tool")
parser.add_argument("--timeout", type=int, default=None)
parser.add_argument("--flags", type=bool, default=None)
parser.add_argument("--hostname", type=str, default=None)
args = parser.parse_args()
defaults = {
"timeout": 300,
"flags": False,
"hostname": "example.com",
}
os.environ["APP_TIMEOUT"] = "600"
config = ConfigManager(
defaults = defaults,
config_file = "./config.ini", # sets "hostname = example2.com"
env_prefix = "APP_",
cli_args = args,
)
print(config.all())
produces:
{'timeout': 600, 'flags': False, 'hostname': 'example2.com'}
License
GNU General Public License v3.0 or later
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
dwgriffin_config-0.1.2.tar.gz
(42.3 kB
view details)
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 dwgriffin_config-0.1.2.tar.gz.
File metadata
- Download URL: dwgriffin_config-0.1.2.tar.gz
- Upload date:
- Size: 42.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
117d4ecda172e6e7d2f01fe055af4a2f08c1e6926fc2fb815b842e2202e22eee
|
|
| MD5 |
b72e775920f4fd6a017314f1b08e714f
|
|
| BLAKE2b-256 |
47c25bf4c984240d9da7418f3df722a850c29fb20e6980f5d72d9c82f62ac90c
|
File details
Details for the file dwgriffin_config-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dwgriffin_config-0.1.2-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be7a9e7b6efd24e83544fe56c5c4f714808b33e6ccdca3b74f0cc1df658daab1
|
|
| MD5 |
bcb846d2c20d7ac8caaedd81998dabde
|
|
| BLAKE2b-256 |
2638f4da150ea542d6c99321e4ac9a2cba0b7f3608483bc007f1c1c7ff89d6cb
|