Skip to main content

Practical and versatile configuration parsing in Python.

Project description

ConfigMate streamlines heavyweight config parsing into a sleek, zero-boilerplate experience that lets you configure with confidence.

Key Features

  • Extensible file format support: - Automatic detection & parsing of all standard config file formats.

  • Environment variable interpolation: - Parse environment variables while keeping defaults in your configuration file.

  • Override files: Segregate base configuration management and DEV/STAG/PROD overrides in separate files.

  • CLI support: Override configuration values with files or values dirctly from an automatically generated command line interface.

  • Type validation: - Custom validation support, and seamless extension for Pydantic’s fantastic validation capabilities.

Get Started with ConfigMate

ConfigMate simplifies your configuration management. Get started with these easy steps:

Installation

Install ConfigMate with all standard features:

pip install "configmate[standard]"

Alternatively, install with specific features (e.g., Pydantic):

pip install "configmate[pydantic]"

Set Up Configuration

  1. Create a Configuration File:

    Define your database configuration in config.yaml:

    # config.yaml
    Database configuration:
        host: localhost
        port: ${DB_PORT:8000}
  2. Integrate with Your Script:

    Use ConfigMate to load and validate configuration in your script:

    # example.py
    import configmate
    import dataclasses
    
    @dataclasses.dataclass
    class DatabaseConfig:
        host: str
        port: int
    
    config = configmate.get_config(
        "config.yaml",
        section='Database configuration',
        validation=DatabaseConfig
    )
    print(config)

Run Your Script with Different Configurations

Execute your script, and override configurations using environment variables or command-line arguments:

# Default configuration
python example.py
>> DatabaseConfig(host='localhost', port=8000)

# Override port using an environment variable
DB_PORT=9000 python example.py
>> DatabaseConfig(host='localhost', port=9000)

# Override host using a command-line argument
python example.py ++host foreignhost
>> DatabaseConfig(host='foreignhost', port=8000)

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

Uploaded Source

Built Distribution

configmate-0.1.7a0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file configmate-0.1.7a0.tar.gz.

File metadata

  • Download URL: configmate-0.1.7a0.tar.gz
  • Upload date:
  • Size: 17.7 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.7a0.tar.gz
Algorithm Hash digest
SHA256 271eeecc296ae38be8ea7a68ae24df6a433bc4af2da6aa1b6182b0d77942e393
MD5 0586a83668e97e0ba9c22bb5e2fab0b3
BLAKE2b-256 471df8f8da6e5efa2eb53e435253aa388c2cdce42611240e0805905dedccadae

See more details on using hashes here.

File details

Details for the file configmate-0.1.7a0-py3-none-any.whl.

File metadata

  • Download URL: configmate-0.1.7a0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 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.7a0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ddf0661b3cd3d7af4c3b5820865da0b0a7e94d7100bb8abfa898a52a0ff04da
MD5 2bb73a0a7c299c717861b9e44868e51e
BLAKE2b-256 850c22bff5d6c0929d78414cdff23f43bf268e848be30b2d5983456384887909

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