Skip to main content

fitb

A practical program extension system.

fitb lets you define extension points which are named points in your program that can be extended externally. Each extension point can any number of extensions associated with it, each providing a different method of extension at that point. Each extension can be configured with configuration options that it defines.

Given an extension point with a number of extensions each accepting their own set of configuration options, fitb makes it easy to construct a default configuration. You can take this default configuration, modify as you see fit (e.g. by loading configuration data from a file), and then activate the extension with the configuration. Activation tells each extension to actually instantiate some object which fulfills the role of extending the extension point.

A motivating example

Suppose you had a program that performed some complex calculation and then reported the result to a user. The nature of the reporting could be to file, to screen, to a database, or in ways you can’t think of right now. To account for this reporting flexibility, you’d like your program reporting to be extensible; users should be able to provide new kinds of reporting without you needing to change your program. This is where fitb comes in.

With fitb, you’d define an extension point for reporting. Extension points are named, so let’s cleverly call the point “reporting”. Then you’d add extensions to the extension point for each of the kinds of reports you want to generate. Critically, other developers can add extensions as well without you having to modify your program.

Each extension will have a name, so let’s consider one called “pdf” that produces a PDF. A critical part of the PDF is the font name and size it will use, so the PDF extension will define two configurable options, “font-size” and “font-name”, each with a default value. Other extensions will have options for their own specific needs.

With the extension point and extensions in place, you can then create a configuration - really just a specially structured dictionary - describing the default config that you can modify if you want. Then, you can activate the extension point with the configuration, thereby asking each reporting extension to instantiate a reporting object based on the information in the configuration. With your collection of reporting extensions available, the user can select which they want to use by specifying the name of the extension they want.

What are configurations?

Concrete examples

See the “examples” directory for examples of how to use fitb.

Metadata

Release files for fitb 3.0.0

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 3.0.0
File Size Uploaded
fitb-3.0.0.tar.gz 7.2 kB Details

Built distribution (wheel)

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

Total release size: 15.1 kB

Release files / fitb-3.0.0.tar.gz

Download URL fitb-3.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0e19296d1d6e4e74d1f15fb60f8f8d875fa1e3a28a8ac3858000b1f5d6292f2f
BLAKE2b-256 checksum
How to use checksums
cedd824ec58c56d7759f90063f9bbbca3e394f59ad099d791e150ac50e72a1d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

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

Download URL fitb-3.0.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23c7e7d31cce09fe824e396183c1dab2c2dece477e278a707917b83315951bb1
BLAKE2b-256 checksum
How to use checksums
10d9858cfded69fe3a144c2ccc28093b769765fcd0b2b44612499442e5474b77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

Release history Release notifications | RSS feed

3.1.0

2 release files

This release

3.0.0 This release

2 release files

2.0.0

2 release files

1.1.2

2 release files

1.0.1

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