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.

Download files

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

Source Distribution

cfbwrite-1.0.1.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfbwrite-1.0.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file cfbwrite-1.0.1.tar.gz.

File metadata

  • Download URL: cfbwrite-1.0.1.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cfbwrite-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b4fe9881d2d7d343d707e9b75874960e95e837a734cb26e55a9fd057fe122a85
MD5 ba5bdb6d5205e0acb7b2fc595843708c
BLAKE2b-256 3ce0594a4cc2efe7afbf8136ec6975222e49d57f585b8f8f54f77b759ccd9c7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfbwrite-1.0.1.tar.gz:

Publisher: release.yml on GuilhermeMarini/cfbwrite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cfbwrite-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cfbwrite-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cfbwrite-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d00c600e03c630d1e122bbc1896d7331c8548d0fd5fb73943de1124004527995
MD5 166aa9f5f6f68f08d4e253e8f1aac487
BLAKE2b-256 b33a27e96d6c2f882e7a8a253f4494c2420164832f64f2e3135b223c168b80ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfbwrite-1.0.1-py3-none-any.whl:

Publisher: release.yml on GuilhermeMarini/cfbwrite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 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