#NEWLINE# def unpack( self , format ) : #NEWLINE# #INDENT# "Unpack bytes and mark them as read.\n\n        Args:\n            format: The struct format string to use to unpack the\n                bytes.\n\n        Raises:\n            IndexError: The format's length is greater than the limit\n                or the number of available bytes.\n        " #NEWLINE# format_length = struct . calcsize ( format ) #NEWLINE# if ( ( format_length > self . _msg_bytes_left ) or ( format_length > len ( self ) ) ) : #NEWLINE# #INDENT# raise IndexError ( 'format too long' ) #NEWLINE# #UNINDENT# res = struct . unpack_from ( format , buffer ( self . _buffer ) , self . _offset ) #NEWLINE# self . _offset += format_length #NEWLINE# self . _msg_bytes_left -= format_length #NEWLINE# return res