Skip to main content

A config library for handling nested incode config groups.

Project description

http://img.shields.io/pypi/v/confspirator.svg

An offshoot of OpenStack’s Oslo.config with a focus on nested configuration groups, and the ability to use yaml.

CONFspirator drops any command-line integrations, or file reading (for now) and expects you to pass in a dictionary which will be parsed against the defined groups. This lets the library for now focus on in-code defaults and config field parsing.

What it can do

CONFspirator focuses on ConfigGroups and registering config fields onto them. With groups themselves being able to be registered on parent groups.

It can also support lazy loading of config for dynamic groups where configs must be registered dynamically from plugins or for other reasons.

Installation

pip install confspirator

Usage

First lets put together a simple ConfigGroup, and register some config values:

# ./root_conf.py
from confspirator import groups, fields

my_root_group = groups.ConfigGroup("my_app")
my_root_group.register_child_config(
    fields.StrConfig("top_level_config", default="some_default"))

sub_group = groups.ConfigGroup("sub_section")
sub_group.register_child_config(fields.BoolConfig("bool_value"))
my_root_group.register_child_config(sub_group)

Now we want to load in our config against this group definition and check the values:

from confspirator import load
from root_conf import my_root_group

conf_dict = {
    "my_app": {
        "top_level_config": "not_the_default",
        "sub_section": {
            "bool_value": True
        }
    }
}
CONF = load.(my_root_group, conf_dict)

print(CONF.top_level_config)
print(CONF.sub_section.bool_value)d

TODO

  • reader logic for reading in data from yaml, json and ini files.

  • exporting an example config

  • potential command-line integrations

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

confspirator-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: confspirator-0.1.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for confspirator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b54ea584f61f1320010d532eb7bbbf9c23f6fb2a6f863f895f6a968a27364549
MD5 4dfad930f865ce88e986cb7a3bb3440a
BLAKE2b-256 38854d9100758f59f83d28b34df99e4fdaa786e79e0daa68a483e5b1332458f0

See more details on using hashes here.

Provenance

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