Skip to main content

A wrapper of python-configuration

Project description

Python Configuration Wrapper

This lib is basically a wrapper of the python-configuration.

It aims at making configuration easy !

Features

Read multi-level configuration values from multiple sources (precedency ordered):

  1. Command line arguments given by --additional-config or -C parameter.

    Example:

    python app.py -C "database.dialect=postgresql" --additional-config "database.host=postgres.mydomain.org" -C "database.user=admin"
    
  2. Environment variables starting with prefix set in the CONFIG_PREFIX environment variable. Level separator is __ (double underscore).

    Example:

    CONFIG_PREFIX=TEST TEST__database__user=root python app.py
    
  3. Config directories given by --config-path or -P parameter. The value of this parameter must be a directory path in which the sub-directories are multi-level keys, and plain-text files content are values. It's very practical when using secrets in containers.

    Example:

    mkdir /var/run/secrets/database -p
    echo -n 123456 > /var/run/secrets/database/password
    python app.py --config-path /var/run/secrets
    
  4. Config files given by --config-file or -F parameter. File formats must be among those handled by python-configuration:

    • json
    • ini
    • yaml
    • toml
    • python

    Example:

    python app.py -F config.json --config-file config.yaml
    

Installation

pip install python-configuration-wrapper

Usage

# import the config object from the module
# you can do this in every python file you want
from python_configuration_wrapper import config

# get some value from a multi-level key
myvalue = config.myfirstlevel.mysecondlevel.mykey

Example

See test

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

python-configuration-wrapper-1.0.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

python_configuration_wrapper-1.0.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file python-configuration-wrapper-1.0.3.tar.gz.

File metadata

  • Download URL: python-configuration-wrapper-1.0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for python-configuration-wrapper-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f59b29953cd9e225a3ef9641a322717436a697cb0b9911e87e41e8e91c715a6b
MD5 e21e3099836364c07f972df3e19f84b9
BLAKE2b-256 db2d961cbad4ab5210ea02d78e5d12d20e9c9f295dfafb39b7d9eab29e130880

See more details on using hashes here.

File details

Details for the file python_configuration_wrapper-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: python_configuration_wrapper-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for python_configuration_wrapper-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 355acd5096f40015831a8992f67c885b1e2e1758cb26b23109a5bafba8168721
MD5 3ac57bb6a585b0873a2a586375974d26
BLAKE2b-256 90e89ccd277b967d767c5d925227e5d8a0ece68e91d67b3b5a91f9dd0711305f

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