On 30Mar2019 09:44, Cameron Simpson <c...@cskk.id.au> wrote:
On 27Mar2019 18:41, Paul Moore <p.f.mo...@gmail.com> wrote:
I'm looking for a library that lets me parse binary data structures.
The stdlib struct module is fine for simple structures, but when it
gets to more complicated cases, you end up doing a lot of the work by
hand (which isn't that hard, and is generally perfectly viable, but
I'm feeling lazy ;-))

I wrote my own: cs.binary, available on PyPI. The PyPI page has is module docs, which I think are ok:

https://pypi.org/project/cs.binary/
[...]
and here's an ISO14496 (the MP4 format) parser using it:
https://pypi.org/project/cs.iso14496/
Of interest is that ISO 14496 uses recursive data structures.

I neglected to mention: with cs.binary you write binary formats as classes (which allows for easy conditional parsing and so forth).

And... normally those classes know how to write themselves back out, which makes for easy transcription and binary data generation.

Conditional binary formats require a class specific .transcribe method (which just yields binary data or some other convenient things including other binary class instances, see doco) but flat records have a default .transcribe.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to