Commit 6988048f by heffnercj

Changed BlockFile to extend io.FileIO instead of the file object

parent 36774f18
...@@ -91,7 +91,7 @@ def unique_file_name(base_name, extension=''): ...@@ -91,7 +91,7 @@ def unique_file_name(base_name, extension=''):
return fname return fname
class BlockFile(io.BufferedReader): class BlockFile(io.FileIO):
''' '''
Abstraction class to handle reading data from files in blocks. Abstraction class to handle reading data from files in blocks.
Necessary for large files. Necessary for large files.
...@@ -109,11 +109,12 @@ class BlockFile(io.BufferedReader): ...@@ -109,11 +109,12 @@ class BlockFile(io.BufferedReader):
# limit disk I/O, but small enough to limit the size of processed data blocks. # limit disk I/O, but small enough to limit the size of processed data blocks.
READ_BLOCK_SIZE = 1 * 1024 * 1024 READ_BLOCK_SIZE = 1 * 1024 * 1024
def __init__(self, fname, length=0, offset=0): def __init__(self, fname, mode='r', length=0, offset=0):
''' '''
Class constructor. Class constructor.
@fname - Path to the file to be opened. @fname - Path to the file to be opened.
@mode - Mode to open the file in (default: 'r').
@length - Maximum number of bytes to read from the file via self.block_read(). @length - Maximum number of bytes to read from the file via self.block_read().
@offset - Offset at which to start reading from the file. @offset - Offset at which to start reading from the file.
...@@ -136,7 +137,7 @@ class BlockFile(io.BufferedReader): ...@@ -136,7 +137,7 @@ class BlockFile(io.BufferedReader):
else: else:
self.length = self.size self.length = self.size
io.BufferedReader.__init__(self, fname, "rb") io.FileIO.__init__(self, fname, mode)
self.seek(self.offset) self.seek(self.offset)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment