Skip to main content

Painless YAML configuration.

Project description

https://github.com/beetbox/confuse/workflows/Build/badge.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, environment variable support, 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.

  • Include configuration values from environment variables. Values undergo automatic type conversion, and nested dicts and lists are supported.

Installation

Confuse is available on PyPI and can be installed using pip:

pip install confuse

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

Uploaded Source

Built Distribution

confuse-2.0.1-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: confuse-2.0.1.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for confuse-2.0.1.tar.gz
Algorithm Hash digest
SHA256 7379a2ad49aaa862b79600cc070260c1b7974d349f4fa5e01f9afa6c4dd0611f
MD5 8aa2b5c90e884af2c8f4b65f3e8d574e
BLAKE2b-256 a77705e2284baff5f2106f74b528b9930caf764d6c400733eb42e617c4234a7d

See more details on using hashes here.

File details

Details for the file confuse-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: confuse-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for confuse-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b9e5bbc70e2cb9b318bcab14d917ec88e21bf1b724365e3815eb16e37aabd2a
MD5 a86739f764dbfa6e37a09e8e9828dc50
BLAKE2b-256 321fcf496479814d41fc252004482deeb90b740b4a6a391a3355c0b11d7e0abf

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