diff --git a/config/dpkg/changelog b/config/dpkg/changelog index da18658f..94c5ff0f 100644 --- a/config/dpkg/changelog +++ b/config/dpkg/changelog @@ -1,5 +1,5 @@ -dfvfs (20161113-1) unstable; urgency=low +dfvfs (20170116-1) unstable; urgency=low * Auto-generated - -- Log2Timeline Sun, 13 Nov 2016 08:31:17 +0100 \ No newline at end of file + -- Log2Timeline Mon, 16 Jan 2017 19:26:57 +0100 \ No newline at end of file diff --git a/dfvfs/__init__.py b/dfvfs/__init__.py index 4d1a9436..e50b4288 100644 --- a/dfvfs/__init__.py +++ b/dfvfs/__init__.py @@ -6,4 +6,4 @@ storage media types and file formats. """ -__version__ = '20161113' +__version__ = '20170116' diff --git a/dfvfs/compression/bzip2_decompressor.py b/dfvfs/compression/bzip2_decompressor.py index 11a82713..7d5fd785 100644 --- a/dfvfs/compression/bzip2_decompressor.py +++ b/dfvfs/compression/bzip2_decompressor.py @@ -26,7 +26,7 @@ def Decompress(self, compressed_data): compressed_data (bytes): compressed data. Returns: - tuple(bytes,bytes): uncompressed data and remaining compressed data. + tuple(bytes, bytes): uncompressed data and remaining compressed data. Raises: BackEndError: if the BZIP2 compressed stream cannot be decompressed. diff --git a/dfvfs/compression/decompressor.py b/dfvfs/compression/decompressor.py index 814eaca4..58e9abc7 100644 --- a/dfvfs/compression/decompressor.py +++ b/dfvfs/compression/decompressor.py @@ -15,5 +15,5 @@ def Decompress(self, compressed_data): compressed_data (bytes): compressed data. Returns: - tuple(bytes,bytes): uncompressed data and remaining compressed data. + tuple(bytes, bytes): uncompressed data and remaining compressed data. """ diff --git a/dfvfs/compression/xz_decompressor.py b/dfvfs/compression/xz_decompressor.py index 3d8feb2e..843497cb 100644 --- a/dfvfs/compression/xz_decompressor.py +++ b/dfvfs/compression/xz_decompressor.py @@ -35,7 +35,7 @@ def Decompress(self, compressed_data): compressed_data (bytes): compressed data. Returns: - tuple(bytes,bytes): uncompressed data and remaining compressed data. + tuple(bytes, bytes): uncompressed data and remaining compressed data. Raises: BackEndError: if the XZ compressed stream cannot be decompressed. diff --git a/dfvfs/compression/zlib_decompressor.py b/dfvfs/compression/zlib_decompressor.py index c4e2c278..3269e02f 100644 --- a/dfvfs/compression/zlib_decompressor.py +++ b/dfvfs/compression/zlib_decompressor.py @@ -32,7 +32,7 @@ def Decompress(self, compressed_data): compressed_data (bytes): compressed data. Returns: - tuple(bytes,bytes): uncompressed data and remaining compressed data. + tuple(bytes, bytes): uncompressed data and remaining compressed data. Raises: BackEndError: if the zlib compressed stream cannot be decompressed. diff --git a/dfvfs/encoding/base16_decoder.py b/dfvfs/encoding/base16_decoder.py index 1cee4352..c3c38e3f 100644 --- a/dfvfs/encoding/base16_decoder.py +++ b/dfvfs/encoding/base16_decoder.py @@ -22,7 +22,7 @@ def Decode(self, encoded_data): encoded_data (byte): encoded data. Returns: - tuple(bytes,bytes): decoded data and remaining encoded data. + tuple(bytes, bytes): decoded data and remaining encoded data. Raises: BackEndError: if the base16 stream cannot be decoded. diff --git a/dfvfs/encoding/base32_decoder.py b/dfvfs/encoding/base32_decoder.py index 375f0890..8bafd2b6 100644 --- a/dfvfs/encoding/base32_decoder.py +++ b/dfvfs/encoding/base32_decoder.py @@ -22,7 +22,7 @@ def Decode(self, encoded_data): encoded_data (byte): encoded data. Returns: - tuple(bytes,bytes): decoded data and remaining encoded data. + tuple(bytes, bytes): decoded data and remaining encoded data. Raises: BackEndError: if the base32 stream cannot be decoded. diff --git a/dfvfs/encoding/base64_decoder.py b/dfvfs/encoding/base64_decoder.py index 784e730a..acf5263a 100644 --- a/dfvfs/encoding/base64_decoder.py +++ b/dfvfs/encoding/base64_decoder.py @@ -22,7 +22,7 @@ def Decode(self, encoded_data): encoded_data (byte): encoded data. Returns: - tuple(bytes,bytes): decoded data and remaining encoded data. + tuple(bytes, bytes): decoded data and remaining encoded data. Raises: BackEndError: if the base64 stream cannot be decoded. diff --git a/dfvfs/encoding/decoder.py b/dfvfs/encoding/decoder.py index 0ab9152f..63d937cd 100644 --- a/dfvfs/encoding/decoder.py +++ b/dfvfs/encoding/decoder.py @@ -15,5 +15,5 @@ def Decode(self, encoded_data): encoded_data (byte): encoded data. Returns: - tuple(bytes,bytes): decoded data and remaining encoded data. + tuple(bytes, bytes): decoded data and remaining encoded data. """ diff --git a/dfvfs/file_io/bde_file_io.py b/dfvfs/file_io/bde_file_io.py index 1e59e064..11d95278 100644 --- a/dfvfs/file_io/bde_file_io.py +++ b/dfvfs/file_io/bde_file_io.py @@ -23,7 +23,7 @@ def _OpenFileObject(self, path_spec): path_spec (PathSpec): path specification. Returns: - A file-like object. + pyvde.volume: BDE volume file-like object. Raises: PathSpecError: if the path specification is incorrect. diff --git a/dfvfs/file_io/compressed_stream_io.py b/dfvfs/file_io/compressed_stream_io.py index 363db474..ad1859b1 100644 --- a/dfvfs/file_io/compressed_stream_io.py +++ b/dfvfs/file_io/compressed_stream_io.py @@ -23,9 +23,9 @@ def __init__( file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - compression_method: optional method used to the compress the data. - file_object: optional parent file-like object. + resolver_context (Context): resolver context. + compression_method (Optional[str]): method used to the compress the data. + file_object (Optional[file]): parent file-like object. Raises: ValueError: if file_object provided but compression_method is not. @@ -68,12 +68,20 @@ def _Close(self): self._decompressor = None def _GetDecompressor(self): - """Retrieves the decompressor.""" + """Retrieves the decompressor. + + Returns: + Decompressor: decompressor. + """ return compression_manager.CompressionManager.GetDecompressor( self._compression_method) def _GetUncompressedStreamSize(self): - """Retrieves the uncompressed stream size.""" + """Retrieves the uncompressed stream size. + + Returns: + int: uncompressed stream size. + """ self._file_object.seek(0, os.SEEK_SET) self._decompressor = self._GetDecompressor() @@ -97,8 +105,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (Optional[PathSpec]): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -127,7 +135,7 @@ def _AlignUncompressedDataOffset(self, uncompressed_data_offset): """Aligns the compressed file with the uncompressed data offset. Args: - uncompressed_data_offset: the uncompressed data offset. + uncompressed_data_offset (int): uncompressed data offset. """ self._file_object.seek(0, os.SEEK_SET) @@ -154,10 +162,10 @@ def _ReadCompressedData(self, read_size): """Reads compressed data from the file-like object. Args: - read_size: the number of bytes of compressed data to read. + read_size (int): number of bytes of compressed data to read. Returns: - The number of bytes of compressed data read. + int: number of bytes of compressed data read. """ compressed_data = self._file_object.read(read_size) @@ -182,11 +190,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -255,12 +263,12 @@ def read(self, size=None): return uncompressed_data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -287,7 +295,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._realign_offset = True def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Returns: + int: current offset in the uncompressed stream. Raises: IOError: if the file-like object has not been opened. @@ -298,7 +309,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the uncompressed stream. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/cpio_file_io.py b/dfvfs/file_io/cpio_file_io.py index 273d5834..bbfe20d9 100644 --- a/dfvfs/file_io/cpio_file_io.py +++ b/dfvfs/file_io/cpio_file_io.py @@ -14,7 +14,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(CPIOFile, self).__init__(resolver_context) self._cpio_archive_file = None @@ -35,8 +35,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional the path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (Optional[PathSpec]): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -71,11 +71,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -103,12 +103,12 @@ def read(self, size=None): return data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. Default is SEEK_SET. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -129,7 +129,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Returns: + int: current offset in the CPIO archived file. Raises: IOError: if the file-like object has not been opened. @@ -140,7 +143,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the CPIO archived file. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/data_range_io.py b/dfvfs/file_io/data_range_io.py index b88662b8..be437ba2 100644 --- a/dfvfs/file_io/data_range_io.py +++ b/dfvfs/file_io/data_range_io.py @@ -11,10 +11,10 @@ class DataRange(file_io.FileIO): """Class that implements a file-like object that maps an in-file data range. - The data range object allows to expose a single partition within - a full disk image as a separate file-like object by mapping - the data range (offset and size) fo the volume on top of the full disk - image. + The data range object allows to expose a single partition within + a full disk image as a separate file-like object by mapping + the data range (offset and size) fo the volume on top of the full disk + image. """ def __init__(self, resolver_context, file_object=None): @@ -24,12 +24,12 @@ def __init__(self, resolver_context, file_object=None): file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional parent file-like object. + resolver_context (Context): resolver context. + file_object (Optional[file]): parent file-like object. """ super(DataRange, self).__init__(resolver_context) - self._file_object = file_object self._current_offset = 0 + self._file_object = file_object if file_object: self._file_object_set_in_init = True @@ -57,8 +57,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -92,8 +92,8 @@ def SetRange(self, range_offset, range_size): (e.g. a single partition within a full disk image) as a file-like object. Args: - range_offset: the start offset of the data range. - range_size: the size of the data range. + range_offset (int): start offset of the data range. + range_size (int): size of the data range. Raises: IOError: if the file-like object is already open. @@ -126,11 +126,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -164,12 +164,12 @@ def read(self, size=None): return data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -193,7 +193,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Returns: + int: current offset in the data range. Raises: IOError: if the file-like object has not been opened. @@ -204,7 +207,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the data range. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/encoded_stream_io.py b/dfvfs/file_io/encoded_stream_io.py index 889c57b3..f199d9a1 100644 --- a/dfvfs/file_io/encoded_stream_io.py +++ b/dfvfs/file_io/encoded_stream_io.py @@ -23,9 +23,9 @@ def __init__( file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - encoding_method: optional method used to the encode the data. - file_object: optional parent file-like object. + resolver_context (Context): resolver context. + encoding_method (Optional[str]): method used to the encode the data. + file_object (Optional[file]): parent file-like object. Raises: ValueError: if file_object provided but encoding_method is not. @@ -67,11 +67,19 @@ def _Close(self): self._encoded_data = b'' def _GetDecoder(self): - """Retrieves the decoder (instance of encodings.Decoder).""" + """Retrieves the decoder. + + Returns: + Decoder: decoder. + """ return encoding_manager.EncodingManager.GetDecoder(self._encoding_method) def _GetDecodedStreamSize(self): - """Retrieves the decoded stream size.""" + """Retrieves the decoded stream size. + + Returns: + int: decoded stream size. + """ self._file_object.seek(0, os.SEEK_SET) self._decoder = self._GetDecoder() @@ -95,8 +103,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -125,7 +133,7 @@ def _AlignDecodedDataOffset(self, decoded_data_offset): """Aligns the encoded file with the decoded data offset. Args: - decoded_data_offset: the decoded data offset. + decoded_data_offset (int): decoded data offset. """ self._file_object.seek(0, os.SEEK_SET) @@ -152,10 +160,10 @@ def _ReadEncodedData(self, read_size): """Reads encoded data from the file-like object. Args: - read_size: the number of bytes of encoded data to read. + read_size (int): number of bytes of encoded data to read. Returns: - The number of bytes of encoded data read. + int: number of bytes of encoded data read. """ encoded_data = self._file_object.read(read_size) @@ -177,7 +185,7 @@ def SetDecodedStreamSize(self, decoded_stream_size): determined separately. Args: - decoded_stream_size: the size of the decoded stream in bytes. + decoded_stream_size (int): size of the decoded stream in bytes. Raises: IOError: if the file-like object is already open. @@ -203,11 +211,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -276,12 +284,12 @@ def read(self, size=None): return decoded_data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -308,7 +316,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._realign_offset = True def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Returns: + int: current offset in the decoded stream. Raises: IOError: if the file-like object has not been opened. @@ -319,7 +330,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the decoded stream. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/encrypted_stream_io.py b/dfvfs/file_io/encrypted_stream_io.py index 7b9ea781..32d615df 100644 --- a/dfvfs/file_io/encrypted_stream_io.py +++ b/dfvfs/file_io/encrypted_stream_io.py @@ -297,7 +297,7 @@ def read(self, size=None): return decrypted_data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: offset (int): offset to seek. @@ -329,10 +329,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._realign_offset = True def get_offset(self): - """Retrieves the current offset into the file-like object. + """Retrieves the current offset into the decrypted stream. Return: - int: current offset into the file-like object. + int: current offset into the decrypted stream. Raises: IOError: if the file-like object has not been opened. @@ -346,7 +346,7 @@ def get_size(self): """Retrieves the size of the file-like object. Returns: - int: size of the file-like object. + int: size of the decrypted stream. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/ewf_file_io.py b/dfvfs/file_io/ewf_file_io.py index 96d065be..4557dec7 100644 --- a/dfvfs/file_io/ewf_file_io.py +++ b/dfvfs/file_io/ewf_file_io.py @@ -20,8 +20,8 @@ def __init__(self, resolver_context, file_object=None): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional file-like object. + resolver_context (Context): resolver context. + file_object (Optional[FileIO]): file-like object. Raises: ValueError: when file_object is set. @@ -46,10 +46,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A file-like object or None. + FileIO: a file-like object or None. Raises: PathSpecError: if the path specification is invalid. @@ -84,7 +84,10 @@ def _OpenFileObject(self, path_spec): return ewf_handle def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the RAW storage media image inside the EWF container. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/fake_file_io.py b/dfvfs/file_io/fake_file_io.py index 3fe51c75..5ae43840 100644 --- a/dfvfs/file_io/fake_file_io.py +++ b/dfvfs/file_io/fake_file_io.py @@ -14,8 +14,8 @@ def __init__(self, resolver_context, file_data): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_data: the fake file data. + resolver_context (Context): resolver context. + file_data (bytes): fake file data. """ super(FakeFile, self).__init__(resolver_context) self._current_offset = 0 @@ -30,8 +30,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -62,11 +62,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -92,12 +92,12 @@ def read(self, size=None): return self._file_data[start_offset:self._current_offset] def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -118,7 +118,7 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -129,7 +129,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/file_io.py b/dfvfs/file_io/file_io.py index a651f11d..85692923 100644 --- a/dfvfs/file_io/file_io.py +++ b/dfvfs/file_io/file_io.py @@ -116,7 +116,7 @@ def read(self, size=None): @abc.abstractmethod def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: offset (int): offset to seek. @@ -141,7 +141,7 @@ def get_offset(self): # Pythonesque alias for get_offset(). def tell(self): - """Returns the current offset into the file-like object.""" + """Retrieves the current offset into the file-like object.""" return self.get_offset() @abc.abstractmethod diff --git a/dfvfs/file_io/file_object_io.py b/dfvfs/file_io/file_object_io.py index a0450091..19d3f136 100644 --- a/dfvfs/file_io/file_object_io.py +++ b/dfvfs/file_io/file_object_io.py @@ -14,8 +14,8 @@ def __init__(self, resolver_context, file_object=None): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional file-like object. + resolver_context (Context): resolver context. + file_object (Optional[FileIO]): file-like object. """ super(FileObjectIO, self).__init__(resolver_context) self._file_object = file_object @@ -41,8 +41,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional the path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (Optional[PathSpec]): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -65,10 +65,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A file-like object. + FileIO: a file-like object. Raises: PathSpecError: if the path specification is incorrect. @@ -84,11 +84,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -99,12 +99,12 @@ def read(self, size=None): return self._file_object.read(size=size) def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -115,7 +115,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._file_object.seek(offset, whence) def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -128,7 +131,10 @@ def get_offset(self): return self._file_object.get_offset() def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/fvde_file_io.py b/dfvfs/file_io/fvde_file_io.py index ca5f48ba..8f25ee8c 100644 --- a/dfvfs/file_io/fvde_file_io.py +++ b/dfvfs/file_io/fvde_file_io.py @@ -23,7 +23,7 @@ def _OpenFileObject(self, path_spec): path_spec (PathSpec): path specification. Returns: - A file-like object. + FileIO: a file-like object. Raises: PathSpecError: if the path specification is incorrect. diff --git a/dfvfs/file_io/gzip_file_io.py b/dfvfs/file_io/gzip_file_io.py index 15693ec8..ef80255f 100644 --- a/dfvfs/file_io/gzip_file_io.py +++ b/dfvfs/file_io/gzip_file_io.py @@ -46,8 +46,8 @@ def __init__(self, resolver_context, file_object=None): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional file-like object. + resolver_context (Context): resolver context. + file_object (Optional[FileIO]): file-like object. Raises: ValueError: when file_object is set. @@ -68,7 +68,7 @@ def _ReadFileHeader(self, file_object): """Reads the file header. Args: - file_object: the file-like object to read from. + file_object (FileIO): file-like object to read from. Raises: FileFormatError: if file format related errors are detected. @@ -123,7 +123,7 @@ def _ReadFileFooter(self, file_object): """Reads the file footer. Args: - file_object: the file-like object to read from. + file_object (FileIO): file-like object to read from. Raises: FileFormatError: if file format related errors are detected. @@ -137,10 +137,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: optional the path specification (instance of PathSpec). + path_spec (Optional[PathSpec]): path specification. Returns: - A file-like object. + FileIO: a file-like object. """ gzip_file_object = resolver.Resolver.OpenFileObject( path_spec.parent, resolver_context=self._resolver_context) diff --git a/dfvfs/file_io/lvm_file_io.py b/dfvfs/file_io/lvm_file_io.py index 319964fa..0ba8a73b 100644 --- a/dfvfs/file_io/lvm_file_io.py +++ b/dfvfs/file_io/lvm_file_io.py @@ -16,7 +16,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of Context). + resolver_context (Context): resolver context. """ super(LVMFile, self).__init__(resolver_context) self._file_system = None @@ -33,8 +33,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -69,15 +69,15 @@ def _Open(self, path_spec=None, mode='rb'): def read(self, size=None): """Reads a byte string from the file-like object at the current offset. - The function will read a byte string of the specified size or - all of the remaining data if no size was specified. + The function will read a byte string of the specified size or + all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -88,12 +88,12 @@ def read(self, size=None): return self._vslvm_logical_volume.read(size) def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -104,7 +104,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._vslvm_logical_volume.seek(offset, whence) def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -115,7 +118,7 @@ def get_offset(self): return self._vslvm_logical_volume.get_offset() def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/ntfs_file_io.py b/dfvfs/file_io/ntfs_file_io.py index ac0a5ff3..066a6b7c 100644 --- a/dfvfs/file_io/ntfs_file_io.py +++ b/dfvfs/file_io/ntfs_file_io.py @@ -18,7 +18,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(NTFSFile, self).__init__(resolver_context) self._file_system = None @@ -37,8 +37,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -86,11 +86,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -103,12 +103,12 @@ def read(self, size=None): return self._fsntfs_file_entry.read(size=size) def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -122,7 +122,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._fsntfs_file_entry.seek(offset, whence) def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -135,7 +138,10 @@ def get_offset(self): return self._fsntfs_file_entry.get_offset() def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/os_file_io.py b/dfvfs/file_io/os_file_io.py index a434deb8..0e557b17 100644 --- a/dfvfs/file_io/os_file_io.py +++ b/dfvfs/file_io/os_file_io.py @@ -22,7 +22,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(OSFile, self).__init__(resolver_context) self._file_object = None @@ -37,8 +37,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -110,11 +110,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -128,12 +128,12 @@ def read(self, size=None): return self._file_object.read(size) def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -150,7 +150,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._file_object.seek(offset, whence) def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -161,7 +164,10 @@ def get_offset(self): return self._file_object.tell() def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/qcow_file_io.py b/dfvfs/file_io/qcow_file_io.py index ae5fd8cf..57bd698a 100644 --- a/dfvfs/file_io/qcow_file_io.py +++ b/dfvfs/file_io/qcow_file_io.py @@ -19,10 +19,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A file-like object. + FileIO: a file-like object. Raises: PathSpecError: if the path specification is incorrect. @@ -38,7 +38,10 @@ def _OpenFileObject(self, path_spec): return qcow_file def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/raw_file_io.py b/dfvfs/file_io/raw_file_io.py index 48c2f3ea..d8babfbf 100644 --- a/dfvfs/file_io/raw_file_io.py +++ b/dfvfs/file_io/raw_file_io.py @@ -20,8 +20,8 @@ def __init__(self, resolver_context, file_object=None): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional file-like object. + resolver_context (Context): resolver context. + file_object (Optional[FileIO]): file-like object. Raises: ValueError: when file_object is set. @@ -46,10 +46,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A file-like object or None. + FileIO: a file-like object or None. Raises: PathSpecError: if the path specification is invalid. @@ -85,7 +85,10 @@ def _OpenFileObject(self, path_spec): return raw_handle def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the RAW storage media image. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/sqlite_blob_file_io.py b/dfvfs/file_io/sqlite_blob_file_io.py index eecbf993..c5727448 100644 --- a/dfvfs/file_io/sqlite_blob_file_io.py +++ b/dfvfs/file_io/sqlite_blob_file_io.py @@ -19,7 +19,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(SQLiteBlobFile, self).__init__(resolver_context) self._blob = None @@ -43,8 +43,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -157,7 +157,7 @@ def GetNumberOfRows(self): """Retrieves the number of rows of the table. Returns: - An integer containing the number of rows. + int: number of rows. Raises: IOError: if the file-like object has not been opened. @@ -181,11 +181,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -209,12 +209,12 @@ def read(self, size=None): return self._blob[start_offset:self._current_offset] def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -235,7 +235,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -246,7 +249,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/tar_file_io.py b/dfvfs/file_io/tar_file_io.py index 81a7b37c..95ccb5a4 100644 --- a/dfvfs/file_io/tar_file_io.py +++ b/dfvfs/file_io/tar_file_io.py @@ -17,7 +17,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(TARFile, self).__init__(resolver_context) self._current_offset = 0 @@ -37,8 +37,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional the path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (Optional[PathSpec]): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -80,11 +80,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -113,12 +113,12 @@ def read(self, size=None): return data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -139,7 +139,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -150,7 +153,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/tsk_file_io.py b/dfvfs/file_io/tsk_file_io.py index c3333039..ab25e692 100644 --- a/dfvfs/file_io/tsk_file_io.py +++ b/dfvfs/file_io/tsk_file_io.py @@ -16,7 +16,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(TSKFile, self).__init__(resolver_context) self._current_offset = 0 @@ -37,8 +37,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -148,11 +148,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -186,12 +186,12 @@ def read(self, size=None): return data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -212,7 +212,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._current_offset = offset def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -223,7 +226,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/tsk_partition_file_io.py b/dfvfs/file_io/tsk_partition_file_io.py index 8cbedec4..f87adf60 100644 --- a/dfvfs/file_io/tsk_partition_file_io.py +++ b/dfvfs/file_io/tsk_partition_file_io.py @@ -14,7 +14,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(TSKPartitionFile, self).__init__(resolver_context) self._file_system = None @@ -28,8 +28,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. diff --git a/dfvfs/file_io/vhdi_file_io.py b/dfvfs/file_io/vhdi_file_io.py index a5cbb312..f17d9cb8 100644 --- a/dfvfs/file_io/vhdi_file_io.py +++ b/dfvfs/file_io/vhdi_file_io.py @@ -20,8 +20,8 @@ def __init__(self, resolver_context, file_object=None): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). - file_object: optional file-like object. + resolver_context (Context): resolver context. + file_object (Optional[FileIO]): file-like object. """ super(VHDIFile, self).__init__(resolver_context, file_object=file_object) self._parent_vhdi_files = [] @@ -44,7 +44,7 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: A file-like object. @@ -82,10 +82,9 @@ def _OpenParentFile(self, file_system, path_spec, vhdi_file): """Opens the parent file. Args: - file_system: the file system (instance of FileSystem). - path_spec: the path specification of the VHDI file (instance of - PathSpec). - vhdi_file: the VHDI file (instance of pyvhdi.file). + file_system (FileSystem): file system of the VHDI file. + path_spec (PathSpec): path specification of the VHDI file. + vhdi_file (pyvhdi.file): VHDI file. Raises: PathSpecError: if the path specification is incorrect. @@ -135,7 +134,10 @@ def _OpenParentFile(self, file_system, path_spec, vhdi_file): self._sub_file_objects.append(file_object) def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/vmdk_file_io.py b/dfvfs/file_io/vmdk_file_io.py index 97f4762d..2dfe3ebc 100644 --- a/dfvfs/file_io/vmdk_file_io.py +++ b/dfvfs/file_io/vmdk_file_io.py @@ -20,10 +20,10 @@ def _OpenFileObject(self, path_spec): """Opens the file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A file-like object. + FileIO: a file-like object. Raises: IOError: if the file-like object could not be opened. @@ -107,7 +107,10 @@ def _OpenFileObject(self, path_spec): return vmdk_handle def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/vshadow_file_io.py b/dfvfs/file_io/vshadow_file_io.py index 96bb3cdb..0d30bca9 100644 --- a/dfvfs/file_io/vshadow_file_io.py +++ b/dfvfs/file_io/vshadow_file_io.py @@ -16,7 +16,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(VShadowFile, self).__init__(resolver_context) self._file_system = None @@ -33,8 +33,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (PathSpec): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -78,11 +78,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: Optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -93,12 +93,12 @@ def read(self, size=None): return self._vshadow_store.read(size) def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: The offset to seek. - whence: Optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -109,7 +109,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._vshadow_store.seek(offset, whence) def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -120,7 +123,10 @@ def get_offset(self): return self._vshadow_store.get_offset() def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/file_io/zip_file_io.py b/dfvfs/file_io/zip_file_io.py index c860728e..c04b82d7 100644 --- a/dfvfs/file_io/zip_file_io.py +++ b/dfvfs/file_io/zip_file_io.py @@ -21,7 +21,7 @@ def __init__(self, resolver_context): """Initializes the file-like object. Args: - resolver_context: the resolver context (instance of resolver.Context). + resolver_context (Context): resolver context. """ super(ZipFile, self).__init__(resolver_context) self._compressed_data = b'' @@ -52,8 +52,8 @@ def _Open(self, path_spec=None, mode='rb'): """Opens the file-like object defined by path specification. Args: - path_spec: optional the path specification (instance of PathSpec). - mode: optional file access mode. The default is 'rb' read-only binary. + path_spec (Optional[PathSpec]): path specification. + mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. @@ -83,7 +83,7 @@ def _AlignUncompressedDataOffset(self, uncompressed_data_offset): """Aligns the compressed file with the uncompressed data offset. Args: - uncompressed_data_offset: the uncompressed data offset. + uncompressed_data_offset (int): uncompressed data offset. Raises: IOError: if the ZIP file could not be opened. @@ -118,7 +118,7 @@ def _ReadCompressedData(self, read_size): """Reads compressed data from the file-like object. Args: - read_size: the number of bytes of compressed data to read. + read_size (int): number of bytes of compressed data to read. """ self._uncompressed_data = self._zip_ext_file.read(read_size) self._uncompressed_data_size = len(self._uncompressed_data) @@ -133,11 +133,11 @@ def read(self, size=None): all of the remaining data if no size was specified. Args: - size: optional integer value containing the number of bytes to read. - Default is all remaining data (None). + size (Optional[int]): number of bytes to read, where None is all + remaining data. Returns: - A byte string containing the data read. + bytes: data read. Raises: IOError: if the read failed. @@ -193,12 +193,12 @@ def read(self, size=None): return uncompressed_data def seek(self, offset, whence=os.SEEK_SET): - """Seeks an offset within the file-like object. + """Seeks to an offset within the file-like object. Args: - offset: the offset to seek. - whence: optional value that indicates whether offset is an absolute - or relative position within the file. + offset (int): offset to seek to. + whence (Optional(int)): value that indicates whether offset is an absolute + or relative position within the file. Raises: IOError: if the seek failed. @@ -221,7 +221,10 @@ def seek(self, offset, whence=os.SEEK_SET): self._realign_offset = True def get_offset(self): - """Returns the current offset into the file-like object. + """Retrieves the current offset into the file-like object. + + Return: + int: current offset into the file-like object. Raises: IOError: if the file-like object has not been opened. @@ -232,7 +235,10 @@ def get_offset(self): return self._current_offset def get_size(self): - """Returns the size of the file-like object. + """Retrieves the size of the file-like object. + + Returns: + int: size of the file-like object data. Raises: IOError: if the file-like object has not been opened. diff --git a/dfvfs/helpers/text_file.py b/dfvfs/helpers/text_file.py index a3852ace..d753d036 100644 --- a/dfvfs/helpers/text_file.py +++ b/dfvfs/helpers/text_file.py @@ -216,10 +216,10 @@ def readlines(self, sizehint=None): # get_offset() is preferred above tell() by the libbfio layer used in libyal. def get_offset(self): - """Returns the current offset into the file-like object.""" + """Retrieves the current offset into the file-like object.""" return self._current_offset # Pythonesque alias for get_offet(). def tell(self): - """Returns the current offset into the file-like object.""" + """Retrieves the current offset into the file-like object.""" return self._current_offset diff --git a/dfvfs/resolver/context.py b/dfvfs/resolver/context.py index 1cea695b..fadbd4d3 100644 --- a/dfvfs/resolver/context.py +++ b/dfvfs/resolver/context.py @@ -13,12 +13,10 @@ def __init__( """Initializes the resolver context object. Args: - maximum_number_of_file_objects: optional maximum number of file-like - objects cached in the context. The - default is 128. - maximum_number_of_file_systems: optional maximum number of file system - objects cached in the context. The - default is 16. + maximum_number_of_file_objects (Optional[int]): maximum number + of file-like objects cached in the context. + maximum_number_of_file_systems (Optional[int]): maximum number + of file system objects cached in the context. """ super(Context, self).__init__() self._file_object_cache = cache.ObjectsCache( @@ -30,10 +28,10 @@ def _GetFileSystemCacheIdentifier(self, path_spec): """Determines the file system cache identifier for the path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - The string that identifiers the VFS object. + str: identifier of the VFS object. """ string_parts = [] @@ -46,8 +44,8 @@ def CacheFileObject(self, path_spec, file_object): """Caches a file-like object based on a path specification. Args: - path_spec: the path specification (instance of PathSpec). - file_object: the file-like object (instance of FileIO). + path_spec (PathSpec): path specification. + file_object (FileIO): file-like object. """ self._file_object_cache.CacheObject(path_spec.comparable, file_object) @@ -55,8 +53,8 @@ def CacheFileSystem(self, path_spec, file_system): """Caches a file system object based on a path specification. Args: - path_spec: the path specification (instance of PathSpec). - file_system: the file system object (instance of vfs.FileSystem). + path_spec (PathSpec): path specification. + file_system (FileSystem): file system object. """ identifier = self._GetFileSystemCacheIdentifier(path_spec) self._file_system_cache.CacheObject(identifier, file_system) @@ -70,10 +68,10 @@ def ForceRemoveFileObject(self, path_spec): """Forces the removal of a file-like object based on a path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - A boolean that indicates the file-like object was cached or not. + bool: True if the file-like object was cached. """ cache_value = self._file_object_cache.GetCacheValue(path_spec.comparable) if not cache_value: @@ -88,10 +86,10 @@ def GetFileObject(self, path_spec): """Retrieves a file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - The file-like object (instance of FileIO) or None if not cached. + FileIO: a file-like object or None if not cached. """ return self._file_object_cache.GetObject(path_spec.comparable) @@ -99,11 +97,11 @@ def GetFileObjectReferenceCount(self, path_spec): """Retrieves the reference count of a cached file-like object. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - An integer containing the reference count or None if there is no - file-like object for the corresponding path specification cached. + int: reference count or None if there is no file-like object for + the corresponding path specification cached. """ cache_value = self._file_object_cache.GetCacheValue(path_spec.comparable) if not cache_value: @@ -115,10 +113,10 @@ def GetFileSystem(self, path_spec): """Retrieves a file system object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - The file system object (instance of vfs.FileSystem) or None if not cached. + FileSystem: a file system object or None if not cached. """ identifier = self._GetFileSystemCacheIdentifier(path_spec) return self._file_system_cache.GetObject(identifier) @@ -127,11 +125,11 @@ def GetFileSystemReferenceCount(self, path_spec): """Retrieves the reference count of a cached file system object. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. Returns: - An integer containing the reference count or None if there is no - file system for the corresponding path specification cached. + int: reference count or None if there is no file system object for + the corresponding path specification cached. """ identifier = self._GetFileSystemCacheIdentifier(path_spec) cache_value = self._file_system_cache.GetCacheValue(identifier) @@ -144,7 +142,7 @@ def GrabFileObject(self, path_spec): """Grabs a cached file-like object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. """ self._file_object_cache.GrabObject(path_spec.comparable) @@ -152,7 +150,7 @@ def GrabFileSystem(self, path_spec): """Grabs a cached file system object defined by path specification. Args: - path_spec: the path specification (instance of PathSpec). + path_spec (PathSpec): path specification. """ identifier = self._GetFileSystemCacheIdentifier(path_spec) self._file_system_cache.GrabObject(identifier) @@ -161,15 +159,15 @@ def ReleaseFileObject(self, file_object): """Releases a cached file-like object. Args: - file_object: the file-like object (instance of FileIO). + file_object (FileIO): file-like object. Returns: - A boolean value indicating true if the file-like object can be closed. + bool: True if the file-like object can be closed. Raises: PathSpecError: if the path specification is incorrect. RuntimeError: if the file-like object is not cached or an inconsistency - is detected in the cache. + is detected in the cache. """ identifier, cache_value = self._file_object_cache.GetCacheValueByObject( file_object) @@ -192,15 +190,15 @@ def ReleaseFileSystem(self, file_system): """Releases a cached file system object. Args: - file_system: the file systemobject (instance of vfs.FileSystem). + file_system (FileSystem): file system object. Returns: - A boolean value indicating true if the file system object can be closed. + bool: True if the file system object can be closed. Raises: PathSpecError: if the path specification is incorrect. RuntimeError: if the file system object is not cached or an inconsistency - is detected in the cache. + is detected in the cache. """ identifier, cache_value = self._file_system_cache.GetCacheValueByObject( file_system) @@ -223,8 +221,8 @@ def SetMaximumNumberOfFileObjects(self, maximum_number_of_file_objects): """Sets the maximum number of cached filei-like objects. Args: - maximum_number_of_file_objects: the maximum number of file-like - objects cached in the context. + maximum_number_of_file_objects (int): maximum number of file-like + objects cached in the context. """ self._file_object_cache.SetMaximumNumberOfCachedValues( maximum_number_of_file_objects) @@ -233,8 +231,8 @@ def SetMaximumNumberOfFileSystems(self, maximum_number_of_file_systems): """Sets the maximum number of cached file system objects. Args: - maximum_number_of_file_systems: the maximum number of file system - objects cached in the context. + maximum_number_of_file_systems (int): maximum number of file system + objects cached in the context. """ self._file_system_cache.SetMaximumNumberOfCachedValues( maximum_number_of_file_systems)