Skip to content

Commit

Permalink
Stop iteration over file when file is empty or exhausted.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwardrop committed Aug 8, 2018
1 parent 33a345f commit 61ad467
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion omniduct/filesystems/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ def flush(self):
def isatty(self):
return self.__io_buffer.isatty()

@property
def newlines(self):
return '\n' # TODO: Support non-Unix newlines?

def read(self, size=-1):
if not self.readable:
raise io.UnsupportedOperation("File not open for reading.")
Expand Down Expand Up @@ -760,7 +764,11 @@ def __iter__(self):
return self

def __next__(self):
return self.readline()
line = self.readline()
if line:
return line
else:
raise StopIteration

next = __next__ # Python 2

Expand Down

0 comments on commit 61ad467

Please sign in to comment.