mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Refactoring
This commit is contained in:
parent
1e48f23f61
commit
0a4227d132
@ -20,13 +20,8 @@ queue = queue # just to use it
|
||||
def check_unpack(seq, index, pattern, size):
|
||||
"""Check that we got size bytes, if so, unpack using pattern"""
|
||||
data = seq[index: index + size]
|
||||
if len(data) == size:
|
||||
return unpack(pattern, data)[0]
|
||||
else:
|
||||
log.warning(
|
||||
"Unpacking of %s bytes failed, insufficient data: %r", size, seq[index:]
|
||||
)
|
||||
raise ValueError(data, "Expected %s bytes" % (size,))
|
||||
assert len(data) == size, "Unexpected data len %d, expected %d" % (len(data), size)
|
||||
return unpack(pattern, data)[0]
|
||||
|
||||
|
||||
def usbyte(seq, index):
|
||||
|
Loading…
x
Reference in New Issue
Block a user