Skip to content

Commit

Permalink
Merge pull request #10 from MurattuW/master
Browse files Browse the repository at this point in the history
IEXParser: fix _get_session_id to support '\n' (fix #9)
  • Loading branch information
lvfrazao committed Oct 30, 2019
2 parents 37d05b3 + 4f9b7a2 commit 078f434
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions IEXTools/IEXparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,19 @@ def _get_session_id(self, file_path: str) -> bytes:
self.version + self.reserved + self.protocol_id + self.channel_id
)
with open(file_path, "rb") as market_file:
for line in market_file:
if iex_header_start in line:
line = line.split(iex_header_start)[1]
return line[:4]
found = False
i = 0
while not found:
cur_chunk = market_file.read(1)
if cur_chunk[0] == iex_header_start[i]:
i += 1
if i == len(iex_header_start):
found = True
else:
i = 0

if found:
return market_file.read(4)
raise ProtocolException("Session ID could not be found in the supplied file")

def read_next_line(self) -> bytes:
Expand Down

0 comments on commit 078f434

Please sign in to comment.