Skip to main content

painless YAML configuration

Project description

https://travis-ci.org/beetbox/confuse.svg?branch=master http://img.shields.io/pypi/v/confuse.svg

Confuse is a configuration library for Python that uses YAML. It takes care of defaults, overrides, type checking, command-line integration, human-readable errors, and standard OS-specific locations.

What It Does

Here’s what Confuse 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, Confuse 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 macOS; %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 Confuse

Confuse’s documentation describes its API in detail.

Credits

Confuse was made to power beets. Like beets, it is available under the MIT license.

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-1.2.0.tar.gz (33.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: confuse-1.2.0.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.8.0 tqdm/4.36.1 CPython/3.7.7

File hashes

Hashes for confuse-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e0bab4c2e1209d2a7d28f7634e735f5f8e46f561556186951377511f1714cca1
MD5 5ca26ae108de025a94bf559e89407306
BLAKE2b-256 23b1b96036a4c09ea141f6892f0a57097ccfff837a8b39981cd6b7806406620f

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