Skip to main content

A one-size-fits-all configuration scheme manager

Project description

Configurave

Lint & Test Python Code Style

Configurave is a one-stop configuration engine that permits writing your configuration as a simple decorated class, and then loading the values from a series of configuration files or providers.

Values loaded from later sources override values provided by earlier sources. Types of the loaded configuration values are checked.

While not currently functional, there are plans and code to write out a default configuration generated directly from the configurave decorated class with .defaults_toml().

This project has undergone MINIMAL testing and work. It is likely very buggy at this time. Stay tuned for more!

Example usage:

from typing import List

from configurave import make_config, ConfigEntry as ce

@make_config()
class MyConfig:
    site_root: str = ce(comment="The root url the site should be mounted on")
    template_root: str = ce(comment="Directory under which templates should be found")
    allowed_hosts: List[str] = ce(
        comment="A comma separated list of hosts that we are permitted to server content to",
        validator=lambda config, value: len(value) > 0,
    )
    token: str = ce(comment="The discord auth token", secret=True)

config = MyConfig(sources=["tests/test-config/readme.toml"])

print(config.site_root, config.template_root, config.allowed_hosts[0], sep="\n")

This will load from a file that looks like:

template_root = "./templates"
allowed_hosts = "mydomain.com,example.example,localhost:8080"

[site]
root = "/"

or

TEMPLATE_ROOT="./templates"
ALLOWED_HOSTS="mydomain.com,example.example,localhost:8080"
SITE_ROOT="/"

and print:

/
./templates
["mydomain.com", "example.example", "localhost:8080"]

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

configurave-0.1.2.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

configurave-0.1.2-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

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