Skip to content

Commit

Permalink
Clean up and changes for linter. (#319)
Browse files Browse the repository at this point in the history
* Clean up and changes for linter.
  • Loading branch information
joachimmetz authored and Onager committed Nov 22, 2018
1 parent 7fbc860 commit fad0b71
Show file tree
Hide file tree
Showing 97 changed files with 1,015 additions and 766 deletions.
27 changes: 15 additions & 12 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs=1

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=pylint.extensions.docparams

# Pickle collected data for later comparisons.
persistent=yes
Expand Down Expand Up @@ -56,22 +56,23 @@ confidence=
# --disable=W"
#
disable=
duplicate-code,
parameter-unpacking,
raw-checker-failed,
assignment-from-none,
bad-inline-option,
locally-disabled,
locally-enabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
no-absolute-import,
metaclass-assignment,
duplicate-code,
eq-without-hash,
file-ignored,
fixme,
locally-disabled,
locally-enabled,
logging-format-interpolation,
metaclass-assignment,
missing-param-doc,
no-absolute-import,
no-self-use,
parameter-unpacking,
raw-checker-failed,
suppressed-message,
too-few-public-methods,
too-many-ancestors,
too-many-boolean-expressions,
Expand All @@ -83,7 +84,9 @@ disable=
too-many-public-methods,
too-many-return-statements,
too-many-statements,
unsubscriptable-object
unsubscriptable-object,
useless-object-inheritance,
useless-suppression

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
7 changes: 5 additions & 2 deletions dfvfs/analyzer/analyzer_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
class AnalyzerHelper(object):
"""Analyzer helper interface."""

# pylint: disable=missing-raises-doc,redundant-returns-doc

@property
def format_categories(self):
"""set[str]: format categories, such as archive file or file system and
are defined in defintions.FORMAT_CATEGORIES.
"""set[str]: format categories, such as archive file or file system.
The format categories are defined in definitions.FORMAT_CATEGORIES.
"""
format_categories = getattr(self, 'FORMAT_CATEGORIES', None)
if format_categories is None:
Expand Down
8 changes: 4 additions & 4 deletions dfvfs/analyzer/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ def AddSpecification(self, specification):
specification.identifier, signature_index)

if signature_identifier in self._signature_map:
raise KeyError(
'Signature {0:s} is already defined in map.'.format(
signature_identifier))
raise KeyError('Signature {0:s} is already defined in map.'.format(
signature_identifier))

signature.SetIdentifier(signature_identifier)
self._signature_map[signature_identifier] = specification
Expand All @@ -143,7 +142,8 @@ def GetSpecificationBySignature(self, signature_identifier):
"""Retrieves a specification mapped to a signature identifier.
Args:
identifier (str): unique signature identifier for a specification store.
signature_identifier (str): unique signature identifier for
a specification store.
Returns:
FormatSpecification: A format specification or None if the signature
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/analyzer/tsk_partition_analyzer_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def AnalyzeFileObject(self, file_object):
try:
pytsk3.Volume_Info(tsk_image_object)
except IOError:
return
return None

return self.type_indicator

Expand Down
2 changes: 2 additions & 0 deletions dfvfs/compression/decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class Decompressor(object):
"""Decompressor interface."""

# pylint: disable=redundant-returns-doc

@abc.abstractmethod
def Decompress(self, compressed_data):
"""Decompresses the compressed data.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/compression/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def GetDecompressor(cls, compression_method):
compression_method = compression_method.lower()
decompressor = cls._decompressors.get(compression_method, None)
if not decompressor:
return
return None

return decompressor()

Expand Down
2 changes: 1 addition & 1 deletion dfvfs/credentials/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def GetCredentials(cls, path_spec):
credentials support.
"""
if not path_spec:
return
return None

return cls._credentials.get(path_spec.type_indicator, None)

Expand Down
2 changes: 2 additions & 0 deletions dfvfs/encoding/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class Decoder(object):
"""Decoder interface."""

# pylint: disable=redundant-returns-doc

@abc.abstractmethod
def Decode(self, encoded_data):
"""Decodes the encoded data.
Expand Down
2 changes: 1 addition & 1 deletion dfvfs/encoding/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def GetDecoder(cls, encoding_method):
encoding_method = encoding_method.lower()
decoder = cls._decoders.get(encoding_method, None)
if not decoder:
return
return None

return decoder()

Expand Down
3 changes: 2 additions & 1 deletion dfvfs/encryption/decrypter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, **kwargs):

super(Decrypter, self).__init__()

# pylint: disable=redundant-returns-doc
@abc.abstractmethod
def Decrypt(self, encrypted_data):
"""Decrypts the encrypted data.
Expand All @@ -32,5 +33,5 @@ def Decrypt(self, encrypted_data):
encrypted_data (bytes): encrypted data.
Returns:
tuple[bytes,bytes]: decrypted data and remaining encrypted data.
tuple[bytes, bytes]: decrypted data and remaining encrypted data.
"""
2 changes: 1 addition & 1 deletion dfvfs/encryption/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def GetDecrypter(cls, encryption_method, **kwargs):
encryption_method = encryption_method.lower()
decrypter = cls._decrypters.get(encryption_method, None)
if not decrypter:
return
return None

return decrypter(**kwargs)

Expand Down
5 changes: 5 additions & 0 deletions dfvfs/file_io/compressed_stream_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def _Open(self, path_spec=None, mode='rb'):
Raises:
AccessError: if the access to open the file was denied.
IOError: if the file-like object could not be opened.
OSError: if the file-like object could not be opened.
PathSpecError: if the path specification is incorrect.
ValueError: if the path specification is invalid.
"""
Expand Down Expand Up @@ -197,6 +198,7 @@ def read(self, size=None):
Raises:
IOError: if the read failed.
OSError: if the read failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -271,6 +273,7 @@ def seek(self, offset, whence=os.SEEK_SET):
Raises:
IOError: if the seek failed.
OSError: if the seek failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -309,6 +312,7 @@ def get_offset(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand All @@ -323,6 +327,7 @@ def get_size(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down
5 changes: 5 additions & 0 deletions dfvfs/file_io/cpio_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def _Open(self, path_spec=None, mode='rb'):
Raises:
AccessError: if the access to open the file was denied.
IOError: if the file-like object could not be opened.
OSError: if the file-like object could not be opened.
PathSpecError: if the path specification is incorrect.
ValueError: if the path specification is invalid.
"""
Expand Down Expand Up @@ -82,6 +83,7 @@ def read(self, size=None):
Raises:
IOError: if the read failed.
OSError: if the read failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -115,6 +117,7 @@ def seek(self, offset, whence=os.SEEK_SET):
Raises:
IOError: if the seek failed.
OSError: if the seek failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand All @@ -139,6 +142,7 @@ def get_offset(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand All @@ -153,6 +157,7 @@ def get_size(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down
6 changes: 6 additions & 0 deletions dfvfs/file_io/data_range_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def _Open(self, path_spec=None, mode='rb'):
Raises:
AccessError: if the access to open the file was denied.
IOError: if the file-like object could not be opened.
OSError: if the file-like object could not be opened.
PathSpecError: if the path specification is incorrect.
ValueError: if the path specification is invalid.
"""
Expand Down Expand Up @@ -99,6 +100,7 @@ def SetRange(self, range_offset, range_size):
Raises:
IOError: if the file-like object is already open.
OSError: if the file-like object is already open.
ValueError: if the range offset or range size is invalid.
"""
if self._is_open:
Expand Down Expand Up @@ -137,6 +139,7 @@ def read(self, size=None):
Raises:
IOError: if the read failed.
OSError: if the read failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -176,6 +179,7 @@ def seek(self, offset, whence=os.SEEK_SET):
Raises:
IOError: if the seek failed.
OSError: if the seek failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -203,6 +207,7 @@ def get_offset(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand All @@ -217,6 +222,7 @@ def get_size(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down
6 changes: 6 additions & 0 deletions dfvfs/file_io/encoded_stream_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _Open(self, path_spec=None, mode='rb'):
Raises:
AccessError: if the access to open the file was denied.
IOError: if the file-like object could not be opened.
OSError: if the file-like object could not be opened.
PathSpecError: if the path specification is incorrect.
ValueError: if the path specification is invalid.
"""
Expand Down Expand Up @@ -187,6 +188,7 @@ def SetDecodedStreamSize(self, decoded_stream_size):
Raises:
IOError: if the file-like object is already open.
OSError: if the file-like object is already open.
ValueError: if the decoded stream size is invalid.
"""
if self._is_open:
Expand Down Expand Up @@ -218,6 +220,7 @@ def read(self, size=None):
Raises:
IOError: if the read failed.
OSError: if the read failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -292,6 +295,7 @@ def seek(self, offset, whence=os.SEEK_SET):
Raises:
IOError: if the seek failed.
OSError: if the seek failed.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down Expand Up @@ -330,6 +334,7 @@ def get_offset(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand All @@ -344,6 +349,7 @@ def get_size(self):
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._is_open:
raise IOError('Not opened.')
Expand Down
Loading

0 comments on commit fad0b71

Please sign in to comment.