Skip to main content

Extensible library for separation of settings from code.

Project description

ClassyConf

ClassyConf is an extensible library for settings & code separation.

It was born as a wrapper around prettyconf, inspired by goodconf.

It adds a declarative way to define settings for your projects contained in a class that can be extended, config objects can be passed around modules and settings are lazyly loaded, plus some other goodies.

It's classy, it's pretty, it's good.

Here is a preview of how to use it. You can find out more documentation at Read the Docs website.

from classyconf import Configuration, Value, EnvFile, IniFile

class AppConfig(Configuration):
    """Configuration for My App"""
    class Meta:
        loaders = [EnvFile(".env"), IniFile("/etc/conf.ini/")]

    DEBUG = Value(default=False, help="Toggle debugging.")
    DATABASE_URL = Value(
        default="postgres://localhost:5432/mydb",
        help="Database connection.")

Later this object can be used to print settings

>>> conf = AppConfig()
>>> print(conf)
DEBUG=True
DATABASE_URL=postgres://localhost:5432/mydb

Or with __repl__()

>>> conf = AppConfig()
>>> conf
DEBUG=True (Toggle debugging.)
DATABASE_URL=postgres://localhost:5432/mydb (Database connection.)

extended

class AppConfig(ClassyConf):
    class Meta:
        loaders = [IniFile("app_settings.ini")]

    DEBUG = Value(default=False)


class DevConfig(AppConfig):
    class Meta:
        loaders = [IniFile("test_settings.ini")]

accessed as dict or object

config.DEBUG
config["DEBUG"]

or passed around

def do_something(cfg):
    if cfg.DEBUG:   # this is evaluated lazily
         return

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

classyconf-0.1.0.tar.gz (10.3 kB view hashes)

Uploaded Source

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