| Index: gslib/file_part.py
|
| ===================================================================
|
| --- gslib/file_part.py (revision 33376)
|
| +++ gslib/file_part.py (working copy)
|
| @@ -1,3 +1,4 @@
|
| +# -*- coding: utf-8 -*-
|
| # Copyright 2013 Google Inc. All Rights Reserved.
|
| #
|
| # Licensed under the Apache License, Version 2.0 (the "License");
|
| @@ -11,18 +12,25 @@
|
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| # See the License for the specific language governing permissions and
|
| # limitations under the License.
|
| +"""FilePart implementation for representing part of a file."""
|
|
|
| +from __future__ import absolute_import
|
| +
|
| import os
|
|
|
| +
|
| class FilePart(file):
|
| + """Subclass of the file API for representing part of a file.
|
| +
|
| + This class behaves as a contiguous subset of a given file (e.g., this object
|
| + will behave as though the desired part of the file was written to another
|
| + file, and the second file was opened).
|
| """
|
| - Subclass of the file API whose only purpose it to behave as a contiguous
|
| - subset of a given file (e.g., this object will behave as though the desired
|
| - part of the file was written to another file, and the second file was opened).
|
| - """
|
|
|
| + # pylint: disable=super-init-not-called
|
| def __init__(self, filename, offset, length):
|
| - """
|
| + """Initializes the FilePart.
|
| +
|
| Args:
|
| filename: The name of the existing file, of which this object represents
|
| a part.
|
| @@ -39,6 +47,7 @@
|
| def __enter__(self):
|
| pass
|
|
|
| + # pylint: disable=redefined-builtin
|
| def __exit__(self, type, value, traceback):
|
| self.close()
|
|
|
| @@ -48,7 +57,7 @@
|
| def read(self, size=-1):
|
| if size < 0:
|
| size = self.length
|
| - size = min(size, self._end - self._fp.tell()) # Only read to our EOF
|
| + size = min(size, self._end - self._fp.tell()) # Only read to our EOF
|
| return self._fp.read(max(0, size))
|
|
|
| def seek(self, offset, whence=os.SEEK_SET):
|
| @@ -64,30 +73,30 @@
|
|
|
| def flush(self, size=None):
|
| raise NotImplementedError('flush is not implemented in FilePart.')
|
| -
|
| +
|
| def fileno(self, size=None):
|
| raise NotImplementedError('fileno is not implemented in FilePart.')
|
| -
|
| +
|
| def isatty(self, size=None):
|
| raise NotImplementedError('isatty is not implemented in FilePart.')
|
| -
|
| +
|
| def next(self, size=None):
|
| raise NotImplementedError('next is not implemented in FilePart.')
|
| -
|
| +
|
| def readline(self, size=None):
|
| raise NotImplementedError('readline is not implemented in FilePart.')
|
| -
|
| +
|
| def readlines(self, size=None):
|
| raise NotImplementedError('readlines is not implemented in FilePart.')
|
| -
|
| +
|
| def xreadlines(self, size=None):
|
| raise NotImplementedError('xreadlines is not implemented in FilePart.')
|
| -
|
| +
|
| def truncate(self, size=None):
|
| raise NotImplementedError('truncate is not implemented in FilePart.')
|
| -
|
| +
|
| def write(self, size=None):
|
| raise NotImplementedError('write is not implemented in FilePart.')
|
| -
|
| +
|
| def writelines(self, size=None):
|
| raise NotImplementedError('writelines is not implemented in FilePart.')
|
|
|