Skip to content

Commit

Permalink
Update docstrings to new style log2timeline#76
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Aug 2, 2016
1 parent 7721421 commit 861506c
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 117 deletions.
2 changes: 1 addition & 1 deletion dfvfs/compression/bzip2_decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/compression/decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
2 changes: 1 addition & 1 deletion dfvfs/compression/xz_decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/compression/zlib_decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/encoding/base16_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/encoding/base32_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/encoding/base64_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/encoding/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
2 changes: 1 addition & 1 deletion dfvfs/file_io/bde_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 30 additions & 16 deletions dfvfs/file_io/compressed_stream_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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.
Expand Down Expand Up @@ -258,9 +266,9 @@ def seek(self, offset, whence=os.SEEK_SET):
"""Seeks 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): the offset to seek.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek failed.
Expand Down Expand Up @@ -289,6 +297,9 @@ def seek(self, offset, whence=os.SEEK_SET):
def get_offset(self):
"""Returns 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.
"""
Expand All @@ -300,6 +311,9 @@ def get_offset(self):
def get_size(self):
"""Returns 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.
"""
Expand Down
24 changes: 15 additions & 9 deletions dfvfs/file_io/cpio_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -106,9 +106,9 @@ def seek(self, offset, whence=os.SEEK_SET):
"""Seeks 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): the offset to seek.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek failed.
Expand All @@ -131,6 +131,9 @@ def seek(self, offset, whence=os.SEEK_SET):
def get_offset(self):
"""Returns 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.
"""
Expand All @@ -142,6 +145,9 @@ def get_offset(self):
def get_size(self):
"""Returns 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.
"""
Expand Down
36 changes: 21 additions & 15 deletions dfvfs/file_io/data_range_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -167,9 +167,9 @@ def seek(self, offset, whence=os.SEEK_SET):
"""Seeks 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): the offset to seek.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek failed.
Expand All @@ -195,6 +195,9 @@ def seek(self, offset, whence=os.SEEK_SET):
def get_offset(self):
"""Returns 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.
"""
Expand All @@ -206,6 +209,9 @@ def get_offset(self):
def get_size(self):
"""Returns 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.
"""
Expand Down
Loading

0 comments on commit 861506c

Please sign in to comment.