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

Uploaded Source

Built Distribution

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

pconf-1.12.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pconf-1.12.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pconf-1.12.0.tar.gz
Algorithm Hash digest
SHA256 a372f829c255edca5903379ba91402a4374b359c998069b50e1d0c97d9900e2c
MD5 27c5f9d7a646a94bcf547dca1e9af63f
BLAKE2b-256 74a7837a156810f796dedd1862f9d10b1d9e63ae1ca075ddd6caa42197736a51

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pconf-1.12.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pconf-1.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73d8f1bffa4e4875aef1588ba304aac75379aa8468c6308d33204a9d90340c10
MD5 dc7fe094f283a9e28cb2a65c0757b22e
BLAKE2b-256 76164f726f85e80f9e52223daf0861e09cc398c5d5f3763ddd8fe346c6c1d338

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