Skip to main content
Help us improve Python packaging – donate today!

Tiny library to parse binary structures into Python objects

Project Description

Destruct is a tiny library to declaratively define data structures and parse them to Python objects.

The library is not mature by any means. Things may break, and API may significantly change in future.

https://secure.travis-ci.org/drdaeman/destruct.png?branch=master

Example

Data structures are declared in a manner somehow similar to Django models:

from destruct import StructBase
import destruct.fields as f

class MyStruct(StructBase):
    timestamp = f.TimestampField()
    value = f.U32Field()

Then, parsing is just creating object:

data = MyStruct(b"\0\0\0\0\0\0\0\xFF")
assert data.timestamp == datetime.datetime.utcfromtimestamp(0)
assert data.value == 255

Release history Release notifications

This version
History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
destruct-0.1.0.tar.gz (4.8 kB) Copy SHA256 hash SHA256 Source None Aug 9, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page