Skip to content

Commit

Permalink
Tweak comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dgburr committed Jan 18, 2025
1 parent 02007c1 commit 6623ef1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion kaitai/python/kaitai_sbp/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

# wrapper object which allows KaitaiStream to be used with a simple byte array
class BufferKaitaiStream(KaitaiStream):
class IOBytes: # "inspired by" BytesIO
# simple emulation of io.BytesIO interface expected by KaitaiStream
class IOBytes:
def __init__(self, buf):
self.buf = buf
self.pos = 0
Expand Down
10 changes: 5 additions & 5 deletions kaitai/python/kaitai_sbp/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def get_next_msg_hybrid2(fileobj):
yield get_flattened_msg(obj)


# hybrid version of sbp2json which uses original parser + kaitai struct to
# avoid calling table_construct.dispatch() and avoids usage of BytesIO
# hybrid version of sbp2json which uses original parser + kaitai struct to avoid
# calling table_construct.dispatch() as well as avoiding usage of io.BytesIO
def get_next_msg_hybrid3(fileobj):
stream = BufferKaitaiStream()
for msg_type, sender, payload_len, buf, crc_read in parse_file_construct(fileobj):
Expand All @@ -90,8 +90,8 @@ def get_next_msg_hybrid3(fileobj):
sys.stderr.write("Skipping unknown message type: {}\n".format(msg_type))
continue

# we can construct an object directly from the payload, but this
# means that we need to fill in the preamble/sender/crc/etc
# we can construct a kaitai object directly from the payload, but this
# means that we need to manually fill in the preamble/sender/crc/etc
payload = buf[SBP_HEADER_LEN:SBP_HEADER_LEN + payload_len]
cls = table_kaitai.TABLE[msg_type]
stream.set_buffer(bytes(payload))
Expand Down Expand Up @@ -134,7 +134,7 @@ def count_messages(filename, fn, cmd=None):
# (to avoid calling table_construct.dispatch())
# 4. hybrid2: use parsing code from construct version + msg_construct.SBP +
# kaitai struct objects (to avoid calling table_construct.dispatch())
# 5. hybrid2: use parsing code from construct version + msg_construct.SBP +
# 5. hybrid3: use parsing code from construct version + msg_construct.SBP +
# kaitai_table.TABLE (to avoid calling table_construct.dispatch() and
# usage of BytesIO)
# 6. perl: based completely upon the perl bindings generated by
Expand Down

0 comments on commit 6623ef1

Please sign in to comment.