File: README.rst

package info (click to toggle)
python-confuse 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 468 kB
  • sloc: python: 2,823; makefile: 112; sh: 8
file content (77 lines) | stat: -rw-r--r-- 3,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Confuse: painless YAML config files
===================================

.. image:: https://github.com/beetbox/confuse/actions/workflows/main.yml/badge.svg
    :target: https://github.com/beetbox/confuse/actions

.. image:: http://img.shields.io/pypi/v/confuse.svg
    :target: https://pypi.python.org/pypi/confuse

**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 <https://pypi.org/project/confuse/>`_ and can be installed
using :code:`pip`:

.. code-block:: sh

    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`_.

.. _ConfigParser: http://docs.python.org/library/configparser.html
.. _YAML: http://yaml.org/
.. _optparse: http://docs.python.org/dev/library/optparse.html
.. _argparse: http://docs.python.org/dev/library/argparse.html
.. _logging: http://docs.python.org/library/logging.html
.. _Confuse's documentation: http://confuse.readthedocs.org/en/latest/usage.html
.. _MIT license: http://www.opensource.org/licenses/mit-license.php
.. _beets: https://github.com/beetbox/beets