Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _read_file_data(self, message_name_filter_list, read_until=None):
"""
read the file data section
:param read_until: an optional file offset: if set, parse only up to
this offset (smaller than)
"""
if read_until is None:
read_until = 1 << 50 # make it larger than any possible log file
try:
# pre-init reusable objects
header = self._MessageHeader()
msg_data = self._MessageData()
curr_file_pos = self._file_handle.tell()
while True:
data = self._file_handle.read(3)
curr_file_pos += len(data)
header.initialize(data)
data = self._file_handle.read(header.msg_size)
curr_file_pos += len(data)
if len(data) < header.msg_size:
break # less data than expected. File is most likely cut
if curr_file_pos > read_until:
if self._debug:
print('read until offset=%i done, current pos=%i' %
(read_until, curr_file_pos))