Skip to content

Commit

Permalink
Improve code coverages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymoch committed Feb 6, 2017
1 parent f8035fb commit 3f73ea3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions csv2sql/core/prefetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import itertools
import tempfile
from builtins import object


class RewindableFileIterator(object):
Expand All @@ -25,23 +26,19 @@ def __iter__(self):
return self

def __next__(self):
return self.next()

def __enter__(self):
return self

def __exit__(self, *args, **kwarg):
self.close()

def next(self):
"""Return the item and move to the next item."""
try:
return next(iter(self._buffer))
except StopIteration:
line = next(self._file)
self._buffer.write(line)
return line

def __enter__(self):
return self

def __exit__(self, *args, **kwarg):
self.close()

@property
def closed(self):
"""Return if the temporary file is closed or not."""
Expand Down

0 comments on commit 3f73ea3

Please sign in to comment.