Simple library for de/serializing binary data
Project description
binpi
binpi aims to provide a simple interface for serializing and deserializing binary file formats.
Usage:
import binpi
class FileHeader:
prop1: binpi.LEInt()
prop2: binpi.LEShort()
prop3: binpi.LEByte()
some_data: binpi.List(binpi.LEByte(), size="prop1")
# deserializing
header_data = binpi.deserialize(FileHeader, binpi.FileReader("./some_path"))
# modify
header_data.prop2 = 200
# serializing
binpi.serialize(header_data, binpi.FileWriter("./another_path"))
For more examples, check ./examples/
How to install:
pip install binpi
TODO:
Fix autocompletion (since we're using for annotationkinda fixed, but it's quite hackybinpi.LEInt()
the IDE's cannot guess the expected type correctly)- Performance improvements (batch struct.un/pack should help)
- Partial structure (de)serializing (optional
from
/to
arguments) - String structure (custom encoding support, sized/c-like)
- Maybe get rid of LE/BE type prefixes and make it the reader's responsibility, not sure if any formats use both LE and BE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
binpi-0.1.5.tar.gz
(3.3 kB
view hashes)