from easy_construct import cs, struct
from construct import *
MyStruct = Struct("MyStruct",
Magic("EZConstruct"),
UBInt32("variable"),
UBInt16("another_var"),
Padding(0x4),
Bytes("array", 13),
Magic("MagicEndsHere"),
)
MyEasyStruct = struct("MyStruct",
_0=cs.Magic("EZConstruct"),
variable=cs.UBInt32,
another_var=cs.UBInt16,
_1=cs.Padding(0x4),
array=cs.Bytes(13),
_2=cs.Magic("MagicEndsHere"),
)
sample_data = 'EZConstruct\xde\xad\xbe\xef\x137\x00\x00\x00\x00Hello, World!MagicEndsHere'
if __name__ == '__main__':
print MyEasyStruct.parse(sample_data)
print MyEasyStruct.parse(sample_data) == MyStruct.parse(sample_data)