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.

Status: scaffold. Code lands here per docs/MIGRATION.md §4.1 of 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.0.tar.gz (25.2 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.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cfbwrite-1.0.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for cfbwrite-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4d4b1c5203dd91aeea0a2c070710bbcf1742242977b8a582df11ad067569389f
MD5 0f93145dbc030a99c155cda1ad6b19d0
BLAKE2b-256 9670fd52270426970bb8f2a1c0ac414fd7d227132367af3d66455fbeb8bd6317

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cfbwrite-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8caa891d2703f36fca93f1f0d289cab397fa94c89068ad96ba4f8e1e9b31a91d
MD5 5d9314ab7e15ad65ee4647326ed39234
BLAKE2b-256 1d82912455cff5d8bf8c343e6b0f7b3db87beaf05f36ca2dd91d699f52e03da8

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

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