Skip to content

Commit f8d4ac6

Browse files
committed
Fix byte array operations
1 parent c6920d4 commit f8d4ac6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kaitaistruct.py

+18
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,24 @@ def process_rotate_left(data, amount, group_size):
370370
# Misc
371371
# ========================================================================
372372

373+
@staticmethod
374+
def int_from_byte(v):
375+
if PY2:
376+
return ord(v)
377+
return v
378+
379+
@staticmethod
380+
def byte_array_index(data, i):
381+
return KaitaiStream.int_from_byte(data[i])
382+
383+
@staticmethod
384+
def byte_array_min(b):
385+
return KaitaiStream.int_from_byte(min(b))
386+
387+
@staticmethod
388+
def byte_array_max(b):
389+
return KaitaiStream.int_from_byte(max(b))
390+
373391
@staticmethod
374392
def resolve_enum(enum_obj, value):
375393
"""Resolves value using enum: if the value is not found in the map,

0 commit comments

Comments
 (0)