Skip to content

zmarvel/struct_parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

struct-parse

struct_parse builds on the struct module in the standard library. struct lets you parse buffers by describing the format similarly to C struct definitions. struct_parse aims to comply with the struct module's format strings, but instead returns a (very flat) abstract syntax tree (AST).

Example

import struct_parse

field_list = struct_parse.parse('hhl')
print(field_list.fields)

This will print:

[<FieldType.FLOAT: 16>, <FieldType.FLOAT: 16>, <FieldType.LONG: 9>]

Use cases

For simply unpacking packed binary data, the struct module does the trick. The goal of this module is to enable the user to do other stuff with the format string--we return a sequence of types instead of a sequence of values.

Compatibility

This library supports only Python 3.

About

Python library for parsing format strings as defined in the struct module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages