Skip to main content

cfbwrite

Write a complete MS-CFB v3 (Microsoft Compound File Binary) container from Python — including streams that changed size.

olefile reads Compound Files well and can replace a stream only with data of exactly the same length. That is enough to rearrange existing content and not enough to add any, so anything that grows a stream needs the container rebuilt. This library rebuilds it.

from cfbwrite import rebuild

rebuild(src="original.rdb", dst="updated.rdb", replacements={
    ("Relays", "QPC1_TR1", "SET_D1.TXT"): new_bytes,   # any size
})

Two properties it is built around, because it came from a tool that writes protection-relay settings files:

  • It verifies its own output. The result is reopened and every stream compared against the source before it is handed over. A bug in the writer surfaces as a failed write, never as a silently corrupt file.
  • It writes atomically. The container is built in a temporary file beside the destination and only then os.replaced into place, so a failure leaves the destination exactly as it was.

Extracted from PAC CT.

Licence

AGPL-3.0-or-later — see LICENSE.

Install

pip install cfbwrite

Requires Python 3.10+ and olefile.

Why it exists

It was pacct/parsers/ole_rebuild.py inside PAC CT, a commissioning toolkit for protective relays. Those relays keep their settings in .rdb files, which are Compound Files, and editing a DNP3 point map there routinely grows a stream. Nothing in the module knows any of that — it is the container format and nothing else — so it lives here instead.

Metadata

Release files for cfbwrite 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cfbwrite 1.0.1
File Size Uploaded Provenance Actions
cfbwrite-1.0.1.tar.gz 26.4 kB With provenance Details for cfbwrite-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 48.0 kB

Release files / cfbwrite-1.0.1.tar.gz

Download URL cfbwrite-1.0.1.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b4fe9881d2d7d343d707e9b75874960e95e837a734cb26e55a9fd057fe122a85
BLAKE2b-256 checksum
How to use checksums
3ce0594a4cc2efe7afbf8136ec6975222e49d57f585b8f8f54f77b759ccd9c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / cfbwrite-1.0.1-py3-none-any.whl

Download URL cfbwrite-1.0.1-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d00c600e03c630d1e122bbc1896d7331c8548d0fd5fb73943de1124004527995
BLAKE2b-256 checksum
How to use checksums
b33a27e96d6c2f882e7a8a253f4494c2420164832f64f2e3135b223c168b80ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Security for cfbwrite 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cfbwrite-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

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