Skip to main content

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.0.1.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dwgriffin_config-0.0.1-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file dwgriffin_config-0.0.1.tar.gz.

File metadata

  • Download URL: dwgriffin_config-0.0.1.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for dwgriffin_config-0.0.1.tar.gz
Algorithm Hash digest
SHA256 22cc009922188fe8af2826a921ec07653a33e439683e689701ff7658e99072d4
MD5 cd7396362f8ffd504ff758c47ee844ae
BLAKE2b-256 51a53032eba2d7d53cc235b09170ad266993772eddb025cc2c4b8b076a218c7a

See more details on using hashes here.

File details

Details for the file dwgriffin_config-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dwgriffin_config-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbe54348a6ae09f00589bb147152cf7601ceb87b67c4d103f4b226aa322ea102
MD5 9d2d148a7489b143300f5b4336ac57f8
BLAKE2b-256 0d70b2ca47cdfe7c5abe8ca71ed03bbaec670eae3e90e65c144f4ea7052635ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page