Utilities¶
- class chapter10.util.BitFormat(src, byteswap=None)¶
Bitstruct wrapper that allows for compiling from readable format strings.
- Parameters:
src (str) – “struct” like format with newline separated pairs of <fmt>, <name> where fmt is a bitstruct format string (generally as “<bitsize>”) and name is the attribute name to use.
byteswap (str) – Optional bitstruct style byteswap description. See bitstruct docs
- Value byteswap:
None
- fmt_str: string¶
The original format string.
- names: list¶
A list of the field names from the format string.
- unpack(data)¶
Use compiled format to unpack data. Uses self.byteswap if provided.
- Parameters:
data (bytes) – Raw data to unpack
- Returns dict:
Unpacked values based on compiled format.
- class chapter10.util.Buffer(io)¶
File wrapper that raises EOF on a short read.