tacconfig

Hierarchical configuration package for containers, web apps, and services


License
BSD-3-Clause
Install
pip install tacconfig==0.5.4

Documentation

TACConfig

https://travis-ci.org/TACC/tacconfig.svg?branch=master https://readthedocs.org/projects/tacconfig/badge/?version=latest

Hierarchical, YAML-based configuration for containers, web apps, and web services

Usage

from tacconfig import config
settings = config.read_config(place_list, config_filename, namespace,
                              update, env, permissive)
  • place_list is the search path. Default: ['/', cwd(), $HOME].
  • config_filename is the name of your application config [config.yml]
  • namespace is the prefix for override environment variables. Default: TACC
  • update is a Boolean. Default: True. Return a synthesis of all members of search path, otherwise, returns only the first encountered.
  • permissive is a Boolean. Default: True. Ignore YAML errors.
  • env is a Boolean. Default: True. Allow specially-named environment variables to override settings.

Example

Given two config files and an environment override as follows:

---
# /config.yml
logs:
    level: "INFO"
---
# /home/tacobot/config.yml
logs:
    level: "DEBUG"
$ export TACC_LOGS_LEVEL="WARNING"
#/usr/bin/env python

from tacconfig import config

settings = config.read_config()

In the code block above, the value of settings.logs.level will be "WARNING". If one unsets the environment variable TACC_LOGS_LEVEL, settings.logs.level will be "DEBUG". If one deletes or renames /home/tacobot/config.yml, settings.logs.level will be INFO.

Also note that, in keeping with this modules expected usage as a configuration management tool, settings can be navigated using dot notation.

Tests

Tests are implemented using tox. To run them, just type tox