Skip to content

Commit

Permalink
No need for cur_offset to be an instance attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
whitews committed Mar 4, 2022
1 parent 6df991a commit ea090a4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions flowio/flowdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, filename_or_handle, ignore_offset_error=False, only_text=Fals
self._fh = open(str(filename_or_handle), 'rb')
else:
self._fh = filename_or_handle
self.cur_offset = 0

current_offset = 0

self._ignore_offset = ignore_offset_error

Expand All @@ -49,14 +50,14 @@ def __init__(self, filename_or_handle, ignore_offset_error=False, only_text=Fals
# Get actual file size for sanity check of data section
self._fh.seek(0, os.SEEK_END)
self.file_size = self._fh.tell()
self._fh.seek(self.cur_offset) # reset to beginning before parsing
self._fh.seek(current_offset) # reset to beginning before parsing

# parse headers
self.header = self.__parse_header(self.cur_offset)
self.header = self.__parse_header(current_offset)

# parse text
self.text = self.__parse_text(
self.cur_offset,
current_offset,
self.header['text_start'],
self.header['text_stop'])

Expand All @@ -73,7 +74,7 @@ def __init__(self, filename_or_handle, ignore_offset_error=False, only_text=Fals
except KeyError:
a_stop = self.header['analysis_end']

self.analysis = self.__parse_analysis(self.cur_offset, a_start, a_stop)
self.analysis = self.__parse_analysis(current_offset, a_start, a_stop)

# parse data
try:
Expand All @@ -92,7 +93,7 @@ def __init__(self, filename_or_handle, ignore_offset_error=False, only_text=Fals
self.events = None
else:
self.events = self.__parse_data(
self.cur_offset,
current_offset,
d_start,
d_stop,
self.text
Expand Down

0 comments on commit ea090a4

Please sign in to comment.