Skip to main content

beelzebub

Beelzebub is a lightweight framework to transform input to output. The base classes aren't meant to be used directly, rather they establish the interfaces of the framework, and provide a basis with which to derive classes for defining a particular transformation workflow.

A workflow consists of a reader class, a writer class, and a processor class. The workflow class instantiates one of each of these classes, and then executes the workflow of reading input from a given source via the reader class, writing output to a given sink via the writer class, and the processor class calls the reader, processes the input, and passes this to the writer.

Both the reader and writer classes are based on a common context manager class. In particular, the open() method can read/write to one of a set of supported iostream types. The iotype must be one of ['file','url','str']. A TypeError exception will be raised otherwise.

The workflow class can optionally set up logging for the workflow (based on the existence of a logger section in the optional configuration dict), and then calls the run() method, passing the source and sink.

As mentioned, an optional configuration dict can be passed when instantiating the workflow object. As a particular workflow will have specific reader, writer and processor classes, the configuration items for each of these components is arbitrary, suited to the particular workflow. However, the framework will look for a toplevel key called reader to pass to the reader class, writer to pass to the writer class, and processor to pass to the processor class. In addition, if a logger key exists, then this will be used to configure logging, via a call to logging.config.dictConfig(conf['logger']).

One of the main uses of the configuration is to specify the iotype for the reader and writer. For example, if the input is read from a file, but the output is to be written to a string, then the configuration should be something like the following:

conf = {'reader': {'iotype': 'file'}, 'writer': {'iotype': 'str'}}
in_file = sys.argv[1]
out_file = None

x = BaseWorkflow(conf=conf)
x.run(in_file, out_file)
print(x.writer.output)

Note that if the output is to be written to a string, then the sink argument (here, out_file) to run() is redundant, and can be set to None. In this case, access the output string via the workflow's writer's output attribute.

If a binary file is to be read or written, then mode should be specified in the corresponding part of the configuration and include the 'b' flag. For example, for reading a binary file from a web server and writing to a local copy:

conf = {
    'reader': {'iotype': 'url', 'mode': 'rb'},
    'writer': {'iotype': 'file', 'mode': 'wb'},
    'logger': {'version': 1, 'loggers': {'beelzebub.base': {'level': 'DEBUG'}}}
}
in_file = 'http://web.server/file.dat'
out_file = './file-copy.dat'

x = BaseWorkflow(conf=conf)
x.run(in_file, out_file)

Release files for beelzebub 1.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 beelzebub 1.0.0
File Size Uploaded
beelzebub-1.0.0.tar.gz 9.6 kB Details

Built distribution (wheel)

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

Total release size: 19.8 kB

Release files / beelzebub-1.0.0.tar.gz

Download URL beelzebub-1.0.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3f94936286fb32a89d37e1e6f4e22ce63bf6f2c1d85b941f0f7dc9d18860b98a
BLAKE2b-256 checksum
How to use checksums
a53f1ea6d5aad76962ac6634c9325ffea7e39596252a7ea00d991c3218dd9dd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.10 Linux/5.15.0-124-generic

Release files / beelzebub-1.0.0-py3-none-any.whl

Download URL beelzebub-1.0.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9cabfb93be206eea30b1c6efc95dd597dd77216d3e28ebf9d1770ee0123c94f
BLAKE2b-256 checksum
How to use checksums
7be91e050d3a79d234ecb22c4f5f29fd1b26d5a8d18049ed4cc17778862608c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.10 Linux/5.15.0-124-generic

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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