fitb
Practical configuration system.
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:
Create a default config
Load user configs from files (e.g. TOML, ini, or whatever)
Merge user configs into the default config.
Metadata
Release files for fitb 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fitb-1.0.0.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fitb-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / fitb-1.0.0.tar.gz
| Download URL | fitb-1.0.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fa00349d2124590c2835cc40a47e8f2a133325fe3a1b0c95908db410fff3cc1
|
|
BLAKE2b-256 checksum How to use checksums |
1400b596f3add55bd48d34f177821c95bd384b04aa97a42cb61debf32666c1f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
|
Release files / fitb-1.0.0-py3-none-any.whl
| Download URL | fitb-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
039751353c6a9e6c8fba9cd5234e8b4ad15f2f84ae51b75970ab98ca2fffca2c
|
|
BLAKE2b-256 checksum How to use checksums |
9c0863c58957405630be27f28281c33ab2a5826046b57ff3bb0aca6de3c79bbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
|