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.0.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distributions

pconf-1.0.1-py3.6.egg (11.7 kB view hashes)

Uploaded Source

pconf-1.0.1-py3.5.egg (11.8 kB view hashes)

Uploaded Source

pconf-1.0.1-py3.4.egg (11.8 kB view hashes)

Uploaded Source

pconf-1.0.1-py3.3.egg (12.1 kB view hashes)

Uploaded Source

pconf-1.0.1-py2.7.egg (11.4 kB view hashes)

Uploaded Source

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