Skip to main content

painless YAML configuration

Project description

https://travis-ci.org/sampsyo/confit.svg?branch=master http://img.shields.io/pypi/v/confer.svg

I’m tired of fiddling around with ConfigParser. I don’t even really like INI syntax. I’m tired of writing boilerplate code to check for missing values, fall back to defaults, override config values with command-line options, and all that. I think a configuration library should be able to handle a lot more for me.

So I’m writing Confit to magically take care of defaults, overrides, type checking, command-line integration, human-readable errors, and standard OS-specific locations. The configuration files will be based on YAML, which is a great syntax for writing down data.

What It Does

Here’s what Confit brings to the table:

  • An utterly sensible API resembling dictionary-and-list structures but providing transparent validation without lots of boilerplate code. Type config['num_goats'].get(int) to get the configured number of goats and ensure that it’s an integer.

  • Combine configuration data from multiple sources. Using layering, Confit allows user-specific configuration to seamlessly override system-wide configuration, which in turn overrides built-in defaults. An in-package config_default.yaml can be used to provide bottom-layer defaults using the same syntax that users will see. A runtime overlay allows the program to programmatically override and add configuration values.

  • Look for configuration files in platform-specific paths. Like $XDG_CONFIG_HOME or ~/.config on Unix; “Application Support” on Mac OS X; %APPDATA% on Windows. Your program gets its own directory, which you can use to store additional data. You can transparently create this directory on demand if, for example, you need to initialize the configuration file on first run. And an environment variable can be used to override the directory’s location.

  • Integration with command-line arguments via argparse or optparse from the standard library. Use argparse’s declarative API to allow command-line options to override configured defaults.

Using Confit

Confit’s documentation describes its API in detail.

Author

Confit is being developed by Adrian Sampson. It’s not done yet, but you’re welcome to use it under the terms of the MIT license. I’m building Confit to use it with a future version of beets.

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

confuse-0.3.0.tar.gz (28.2 kB view details)

Uploaded Source

File details

Details for the file confuse-0.3.0.tar.gz.

File metadata

  • Download URL: confuse-0.3.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for confuse-0.3.0.tar.gz
Algorithm Hash digest
SHA256 146e49d1ec9a383896bc798aaed41d1431d24cba9c1e747a7418e2863a6f6022
MD5 9fb327ae18a1efa33a0431cd94c8e46c
BLAKE2b-256 ee14d5df2e269f7809f49fefda2e0a2a285c407f73ed997e7b91dc93bcd98c2b

See more details on using hashes here.

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