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 2.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 2.0.0
File Size Uploaded
fitb-2.0.0.tar.gz 6.7 kB Details

Built distribution (wheel)

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

Total release size: 13.9 kB

Release files / fitb-2.0.0.tar.gz

Download URL fitb-2.0.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5fc5da696f5d2771535ce7ab21b8ad2b05930ccb36e873963bf87ffd3f15486d
BLAKE2b-256 checksum
How to use checksums
a35dfe4e78c2f012cd49abecf620ce993e571503c5e089ab660b5135ee13b111
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-2.0.0-py3-none-any.whl

Download URL fitb-2.0.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de71f1658e0b008215a54d7889f91c09542448c7d7292f41821b9cde34464dfd
BLAKE2b-256 checksum
How to use checksums
8ae7c2d82b287be249bbae60331d76523f9d95c8220a6c4b68db41ef9f9d8e25
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 history Release notifications | RSS feed

3.1.0

2 release files

3.0.0

2 release files

This release

2.0.0 This release

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