destruct

Tiny library to parse binary structures into Python objects
Download

destruct Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Aleksey Zhukov
  • Publisher web site:
  • https://github.com/drdaeman/

destruct Tags


destruct Description

destruct is a tiny Python 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.ExampleData structures are declared in a manner somehow similar to Django models:from destruct import StructBaseimport destruct.fields as fclass 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 == 255Product's homepage


destruct Related Software