Skip to main content

Practical configuration system

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fitb-3.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

fitb-3.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file fitb-3.1.0.tar.gz.

File metadata

  • Download URL: fitb-3.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for fitb-3.1.0.tar.gz
Algorithm Hash digest
SHA256 8062500162bf178c520280d5851182173e1f6050d0ba25c83d3602a7db97e9a3
MD5 e39711f27d794c5387b83a617b4dd611
BLAKE2b-256 b4a5a6c08d08b0051c73939e2422b387869520a1d68c8187a5ae63918d85b9eb

See more details on using hashes here.

File details

Details for the file fitb-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: fitb-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for fitb-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2240ed4e7c6dd09b7f240433a26bc83c4b0b7f350ad94ad1fb926e3f4137f7
MD5 a5521cd667097d546e9112455671ee29
BLAKE2b-256 67b15e079454cb5285e019d962662f9d4086efce6e92faeacd12fb0ed6e4ec34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page