Skip to main content

Configuration specified through documentation, supporting multiple formats.

Project description

Configuration specified through documentation.

Installation

From the project root directory:

$ python setup.py install

Or from pip:

$ pip install doconf

Usage

Use –help/-h to view info on the arguments:

$ doconf --help

usage: doconf [-h] {find,validate,generate} ...

positional arguments:
  {find,validate,generate}
    find                find where the config file would be loaded from
    validate            validate your config files match the format
    generate            generate example config files

optional arguments:
  -h, --help            show this help message and exit

Find will show you where the config would be loaded from in the current environment:

$ doconf find --help
usage: doconf find [-h] class_path

positional arguments:
  class_path  path to the module and class, eg:
              custom_example.config:CustomConfig

optional arguments:
  -h, --help  show this help message and exit

Here we can see where the environment would discover a config specified by the class CustomConfig in the directory examples/my_example_app/config.py:

$ doconf find examples.my_example_app.config:CustomConfig

Validate will find your config and parse it, tell you whether it has all required variables and show you the values:

$ doconf validate --help | sed 's/        /    /g'
usage: doconf validate [-h] [--config-path CONFIG_PATH] [--env ENV] class_path

positional arguments:
  class_path            path to the module and class, eg:
                        custom_example.config:CustomConfig

optional arguments:
  -h, --help            show this help message and exit
  --config-path CONFIG_PATH, -c CONFIG_PATH
                        direct path to config
  --env ENV, -e ENV     the environment to use

This will validate that the config passed via –config-path matches the format, and we will see the values it sets:

$ doconf validate examples.my_example_app.config:CustomConfig --config-path examples/my_example_app/my_example_app.cfg

Generate will dump example configuration files for you to provide as examples:

$ doconf generate --help
usage: doconf generate [-h] [--out OUT] class_path

positional arguments:
  class_path         path to the module and class, eg:
                     custom_example.config:CustomConfig

optional arguments:
  -h, --help         show this help message and exit
  --out OUT, -o OUT  output directory, default to current directory

This will dump out an example documented config for the default environment and the production environment:

$ doconf generate examples.my_example_app.config:CustomConfig --out .

Release Notes

0.1.0:
  • Implemented main logic, including parser and DoconfConfig class.

  • Implemented CLI tools: find, validate, generate.

  • Added examples.

0.0.1:
  • Project created.

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

doconf-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file doconf-0.1.0.tar.gz.

File metadata

  • Download URL: doconf-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.3

File hashes

Hashes for doconf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 059cb7284a50a311c3f1764270850a1aba293a8bb891ff9b69631113850ad403
MD5 23946c21ae1811ecb617ee27144ffda1
BLAKE2b-256 314d79a0821ef24db089114171cffb364dd6e3375e133011f677c078383b7de6

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