Skip to main content

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
    

    If no config file is given, the lib will look for config.{yaml|json|ini|toml|python} in the working directory.

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

Metadata

Release files for python-configuration-wrapper 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-configuration-wrapper 1.2.0
File Size Uploaded
python-configuration-wrapper-1.2.0.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-configuration-wrapper 1.2.0
File Interpreter ABI Platform
python_configuration_wrapper-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / python-configuration-wrapper-1.2.0.tar.gz

Download URL python-configuration-wrapper-1.2.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
668a76dd51f84eb962f2a66e41d0074d691fec2d7a0c8d8acca216af5df8ece1
BLAKE2b-256 checksum
How to use checksums
2f54124f3fae43f2f14bc6ebe7a697e067418decc9cf41ecd431a6ef14baaf5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.7.1 requests/2.26.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.1

Release files / python_configuration_wrapper-1.2.0-py3-none-any.whl

Download URL python_configuration_wrapper-1.2.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80885c6e246bec169ecc6c2f0150729a724d432a7a286404891563d470a2a230
BLAKE2b-256 checksum
How to use checksums
9cbe5781621d063820f63cac4a5162b62237da3a9982d04bf25bd8536ca6e4ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.7.1 requests/2.26.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.1

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page