Skip to main content

Hierarchical python configuration with files, environment variables, command-line arguments.

Project description

Hierarchical python configuration with files, environment variables, command-line arguments.

See GitHub for detailed documentation.

Example

from pconf import Pconf
import json

"""
Setup pconf config source hierarchy as:
  1. Environment variables
  2. A JSON file located at 'path/to/config.json'
"""
Pconf.env()
Pconf.file('path/to/config.json', encoding='json')

# Get all the config values parsed from the sources
config = Pconf.get()

# Just print everything nicely
print json.dumps(config, sort_keys=True, indent=4)

Run the above script:

pip install pconf
python example.py

The output should be something like this:

{
    "HOSTNAME": "bb30700d22d8",
    "TERM": "xterm",
    "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "PWD": "/",
    "SHLVL": "1",
    "HOME": "/root",
    "no_proxy": "*.local, 169.254/16",
    "_": "/usr/bin/env",
    "example": {
        "another": "stuff",
        "key": "value"
    }
}

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

pconf-1.11.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

pconf-1.11.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pconf-1.11.0.tar.gz.

File metadata

  • Download URL: pconf-1.11.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pconf-1.11.0.tar.gz
Algorithm Hash digest
SHA256 baf72f88e7d598d672de6a8e14477f70dd05df2572aa46de07885dd9ac81215b
MD5 e7a30310d7ec009f886f5636f28876e6
BLAKE2b-256 191aa22e753a09d38fe29a7915176cafac3b1d9fb03b092c96e3692148928660

See more details on using hashes here.

File details

Details for the file pconf-1.11.0-py3-none-any.whl.

File metadata

  • Download URL: pconf-1.11.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pconf-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a972b17cf9a5a1486546460dbde46581c9c1f8e627182861c8e6e2ae54b2693
MD5 a072c9742d7884a10faea951ded0f52b
BLAKE2b-256 5035dd8526b725222fa4af8b2d03f55d15ff8207280d82fd9d6d8066e208b947

See more details on using hashes here.

Supported by

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