Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Multi-profile supported, flexible config library

Project description

Logo

octoconf

Python Package Build Status Server Dependency Status Code Quality Server Test Coverage License

Multi-profile supported, flexible config library for Python 2 & 3.

Features

  • Allow multiple config profiles in one YAML file
  • Allow include multiple YAML files
  • Overridable profile selection from code for special use-cases (e.g. config for testing)
  • Inheritable config profiles, what makes profile merges by dictionaries. (the native YAML bookmarking is also available)
  • Can use variables in the config file

Installation

pip install octoconf

Config format

An octoconf config file is pure YAML file with some reserved keywords:

  • USED_CONFIG>: <node_name> in the file root
    you can specify the name of default config profile
  • <INCLUDE: <yml_path(s)> in the file root
    this octoconf file(s) will be included
  • <BASE: <node_name> in the 2nd level
    this will used for making (merge based) inheritance between profiles

The profile nodes should be on 1st level!

Usage

  • You can load config from string with loads():
    import octoconf
    
    config = octoconf.loads(yaml_string)
    print(config)
    
  • Or directly from StringIO (e.g. from file) with load():
    import octoconf
    
    with open('config.yml') as fd:
        config = octoconf.load(fd)
    print(config)
    

Please check the features docs for explain octoconf’s features.

Examples YAML files

USED_CONFIG>: UserConfig
<INCLUDE: vendor.defaults.yml


# This config overrides the production preset (from vendor.defaults.yml file)
UserConfig:
  <BASE: ProductionConfig

  App:
    TITLE: "Amazing Foobar"

  Flask:
    SQLALCHEMY_DATABASE_URI: "sqlite:///${SERVER}/app.sqlite"

For more examples, please check the examples directory.

Bugs

Bugs or suggestions? Visit the issue tracker.

Project details


Release history Release notifications

This version
History Node

0.2.0

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
octoconf-0.2.0-py2.py3-none-any.whl (7.3 kB) Copy SHA256 hash SHA256 Wheel 2.7 Mar 28, 2016
octoconf-0.2.0.tar.gz (17.4 kB) Copy SHA256 hash SHA256 Source None Mar 28, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page