cfbpy
cfbpy is a Python package that allows you to compress and decompress compound file binary formats,
similar to how zip/unzip works for regular zip files.
It provides an easy-to-use interface for handling compound files through the CompoundFile class.
Features
- Compress a directory into a compound file format.
- Decompress a compound file back into a directory.
Installation
cfbpy is written in pure Python and has no dependencies. You can install cfbpy via pip:
pip install cfbpy
Or add it to a uv project:
uv add cfbpy
Usage
Here’s how you can use cfbpy to compress and decompress files:
Compress a Directory
from cfbpy import compress
compress('path/to/directory', 'path/to/output.cfb')
Decompress a Compound File
from cfbpy import decompress
decompress('path/to/input.cfb', 'path/to/extracted_directory')
The same functions are also available as CompoundFile.compress and CompoundFile.decompress.
Methods
compress(src, dest=None): Compresses the contents of thesrcdirectory into a compound file atdest(default:<src>.cfb).decompress(src, dest=None): Decompresses the compound file fromsrcto the directorydest(default:srcwithout its extension).
Compound file names are limited by the format, so compress raises ValueError when a file or directory name
- is longer than 31 UTF-16 code units,
- contains any of
/ \ : !, or - differs from a sibling only in letter case.
decompress raises CompoundFileError (a subclass of ValueError) if the input is not a valid compound file, and ValueError for entry names that would escape the destination directory, such as ...
Files are written as a major version 3 compound file (512-byte sectors). Both major version 3 and 4 (4096-byte sectors) files can be decompressed.
Development
The project is managed with uv.
uv sync # create .venv with the package and dev dependencies
uv run pytest # run tests
uv run python benchmarks/bench.py # measure compress/decompress time and memory
uv build # build sdist and wheel into dist/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
Metadata
Release files for cfbpy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cfbpy-1.0.0.tar.gz | 11.9 kB | Without provenance | Details for cfbpy-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cfbpy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for cfbpy-1.0.0-py3-none-any.whl |
Total release size: 25.7 kB
Release files / cfbpy-1.0.0.tar.gz
| Download URL | cfbpy-1.0.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea127d48e2902b1daf2c3af51b2a06c6d72064cc8379547374a060bb165751b5
|
|
BLAKE2b-256 checksum How to use checksums |
352c364c55a54dc12890fdd957a55ce3063fd2be0199d61a3e43fe67bf31e8d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cfbpy-1.0.0-py3-none-any.whl
| Download URL | cfbpy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
832bb5400cca5b54d6c1165901112d139ce3e69b4c8a1926c01e65bd2e66522f
|
|
BLAKE2b-256 checksum How to use checksums |
2ce461cbcef36dace9ac48e523bb646ad36354ced6993e7b8d42de863e0401f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for cfbpy 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.