Skip to main content

A universal configuration parser for Python.

Project description

configmate: universal, practical configuration parser for Python.

With support for multiple file format backends, this package provides robust validation and allows for configuration overrides. Engineered for straightforward and reliable integration into Python applications.

Key Features:

  • Support for Multiple File Formats: ConfigMate supports JSON, YAML, TOML and XML formats.
  • Overrides: Allows for easy management of multiple config_files.
  • Environment Variable Interpolation using the syntax ${VAR_NAME:default_value}.

Example:

Let's say you have a Python app that needs to be deployed in multiple environments. You want to be able to configure the application using config files, but you also want to be able to override certain settings in the production environment:

// config.json (This is the default configuration file.)
{
    "db": "DEV",
    "port": "${PORT:8080}" // default to 8080 if PORT is not set in env
}

// prod_config.json (overrides certain settings in the prod environment.)
{
    "db": "PROD", // overrides db in prod deployment
}

Here's how you use configmate to load and validate these configurations in a Python application:

# app.py
import configmate
import pydantic


class Config(pydantic.BaseModel):
    db: str
    port: int


config = configmate.get_config(
    "config.json",  # main config
    "prod_config.json",  # prod overlay
    validation=lambda kwargs: Config(**kwargs),
)

print(config)

Now, when you run the application, the configuration files are parsed in order and you can override the port using an environment variable:

PORT=9000 python app.py
## db='PROD' port=9000

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

configmate-0.1.3.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

configmate-0.1.3-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file configmate-0.1.3.tar.gz.

File metadata

  • Download URL: configmate-0.1.3.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for configmate-0.1.3.tar.gz
Algorithm Hash digest
SHA256 59f7424546e4ba2569f89caf6a5bf9dd2faa782c2cf2911666a040652dc8d683
MD5 14dae45866d6a7312f4e5a6770a81a7a
BLAKE2b-256 f9961dfec9e82f99501409371c0f2dd4e49431d487e48b20ea0b29dd3dd06938

See more details on using hashes here.

File details

Details for the file configmate-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: configmate-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for configmate-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dcfebf6136a9018cdf67496f9d7b0ecad8448a31e9718e86e465df49fcbc8dda
MD5 bd8aa51c2f22da1c2acc454c876e69da
BLAKE2b-256 5b2e15fe80c0d17c40622c0d715a4bfbf27bfbfb7b34eff72117547041f98497

See more details on using hashes here.

Supported by

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