Skip to main content

fitb

A practical configuration system for Python.

With fitb, you specify a collection of configuration options that your program/library/whatever needs. fitb then helps you construct configuration objects and merge them together.

A configuration object is simply a dict, so fitb is helping you build dicts. A configuration option specifies a path into the dict - that is, a sequence of keys into the dict and subdicts - along with a description of the option and a default value.

Quick start

The first thing you do with fitb is define a collection of config options:

options = [(('my-app', 'screen'), fitb.Option('width', 'Width of screen', 100)),
           (('my-app', 'screen'), fitb.Option('height', 'Height of screen', 200))]

Each entry in the list specifies a prefix path and the option itself. From this we can build a default config option:

config = fitb.build_default_config(options)

This gives us an object like this:

{'my-app': {'screen': {'width': 100, 'height': 200}}}

with which can do things like this:

print(config['my-app']['screen']['width']

or work with subconfigs:

screen_config = config['my-app']['screen']
print(screen_config['width'])

You can also merge configs together, putting entries from one config into another, possibly overwriting exiting options. That looks like this:

fitb.merge(dest=config, src={'my-app': {'screen': {'width': 400}}})

# The `dest` config has been updated
assert config['my-app']['screen']['width'] == 400

This ability to merge is useful because you can do things like:

  1. Create a default config

  2. Load user configs from files (e.g. TOML, ini, or whatever)

  3. Merge user configs into the default config.

Metadata

Release files for fitb 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fitb 1.0.1
File Size Uploaded
fitb-1.0.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fitb 1.0.1
File Interpreter ABI Platform
fitb-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / fitb-1.0.1.tar.gz

Download URL fitb-1.0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
46846963d9cb0e5a79510c70bfeb33cc6e480f084d0215d3d00885d9c858e433
BLAKE2b-256 checksum
How to use checksums
6aeb356d39e3fa01e71b2d17b8dedc122991ac376b2cbd32449badc724cd5485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.8.0a3+

Release files / fitb-1.0.1-py3-none-any.whl

Download URL fitb-1.0.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b7f378f5ebf0e1d232e7b78558cb51a66b1788f9c80169b70b1cb7abab56b0c
BLAKE2b-256 checksum
How to use checksums
9f58c9113b91540ef24d7c2e275d94a9ea6700426a80600e1683fe2f6971e179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.8.0a3+

Release history Release notifications | RSS feed

3.1.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.1.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page