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.1.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.1.0
File Size Uploaded
fitb-3.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / fitb-3.1.0.tar.gz

Download URL fitb-3.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8062500162bf178c520280d5851182173e1f6050d0ba25c83d3602a7db97e9a3
BLAKE2b-256 checksum
How to use checksums
b4a5a6c08d08b0051c73939e2422b387869520a1d68c8187a5ae63918d85b9eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

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

Download URL fitb-3.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a2240ed4e7c6dd09b7f240433a26bc83c4b0b7f350ad94ad1fb926e3f4137f7
BLAKE2b-256 checksum
How to use checksums
67b15e079454cb5285e019d962662f9d4086efce6e92faeacd12fb0ed6e4ec34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

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