Skip to content

Commit

Permalink
Use with statement in VcfGz class
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Aug 7, 2017
1 parent 5cc71d2 commit 13d32ee
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/galaxy/datatypes/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def displayable( self, dataset ):
return False

def get_chunk(self, trans, dataset, offset=0, ck_size=None):
f = compression_utils.get_fileobj(dataset.file_name)
f.seek(offset)
ck_data = f.read(ck_size or trans.app.config.display_chunk_size)
if ck_data and ck_data[-1] != '\n':
cursor = f.read(1)
while cursor and cursor != '\n':
ck_data += cursor
with compression_utils.get_fileobj(dataset.file_name):
f.seek(offset)
ck_data = f.read(ck_size or trans.app.config.display_chunk_size)
if ck_data and ck_data[-1] != '\n':
cursor = f.read(1)
last_read = f.tell()
while cursor and cursor != '\n':
ck_data += cursor
cursor = f.read(1)
last_read = f.tell()
return dumps( { 'ck_data': util.unicodify( ck_data ),
'offset': last_read } )

Expand Down Expand Up @@ -1144,7 +1144,7 @@ def sniff(self, filename):

def get_chunk(self, trans, dataset, chunk):
ck_index = int(chunk)
f = compression_utils.get_fileobj(dataset.file_name)
f = open(dataset.file_name)
f.seek(ck_index * trans.app.config.display_chunk_size)
# If we aren't at the start of the file, seek to next newline. Do this better eventually.
if f.tell() != 0:
Expand Down

0 comments on commit 13d32ee

Please sign in to comment.