From bb8729487dfd735864d3988f07e9e24910d197fe Mon Sep 17 00:00:00 2001 From: Vladimir Diaz Date: Wed, 15 Nov 2017 16:34:34 -0500 Subject: [PATCH] Resolve Pylint's identified [E]rrors in the codebase Signed-off-by: Vladimir Diaz --- tuf/client/updater.py | 15 +++++++-------- tuf/developer_tool.py | 2 +- tuf/download.py | 2 +- tuf/formats.py | 2 +- tuf/log.py | 3 ++- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tuf/client/updater.py b/tuf/client/updater.py index 08f60218..17c3fb41 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -2173,8 +2173,10 @@ def targets_of_role(self, rolename='targets'): def get_one_valid_targetinfo(self, target_filepath): """ - Return the target information of 'target_filepath', and update its - corresponding metadata, if necessary. + Return the target information for 'target_filepath', and update its + corresponding metadata, if necessary. 'target_filepath' must match + exactly as it appears in metadata, and should not contain URL encoding + escapes. target_filepath: @@ -2202,10 +2204,6 @@ def get_one_valid_targetinfo(self, target_filepath): # Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch. securesystemslib.formats.RELPATH_SCHEMA.check_match(target_filepath) - # 'target_filepath' might contain URL encoding escapes. - # http://docs.python.org/2/library/urllib.html#urllib.unquote - target_filepath = six.moves.urllib.parse.unquote(target_filepath) - if not target_filepath.startswith('/'): target_filepath = '/' + target_filepath @@ -2214,8 +2212,9 @@ def get_one_valid_targetinfo(self, target_filepath): # Raise an exception if the target information could not be retrieved. if target is None: - logger.error(target_filepath + ' not found.') - raise tuf.exceptions.UnknownTargetError(target_filepath + ' not found.') + logger.error(repr(target_filepath) + ' not found.') + raise tuf.exceptions.UnknownTargetError(repr(target_filepath) + ' not' + ' found.') # Otherwise, return the found target. else: diff --git a/tuf/developer_tool.py b/tuf/developer_tool.py index b8463d69..9f99f880 100755 --- a/tuf/developer_tool.py +++ b/tuf/developer_tool.py @@ -432,7 +432,7 @@ def status(self): except securesystemslib.exceptions.Error as e: signable = e[1] - self._log_status(self._project_name, signable, repository_name) + self._log_status(self._project_name, signable, self._repository_name) return finally: diff --git a/tuf/download.py b/tuf/download.py index f9e3f69e..0676cea2 100755 --- a/tuf/download.py +++ b/tuf/download.py @@ -651,7 +651,7 @@ def _check_downloaded_length(total_downloaded, required_length, logger.debug('Good average download speed: ' + repr(average_download_speed) + ' bytes per second') - raise securesystemslib.exceptions.DownloadLengthMismatchError(required_length, total_downloaded) + raise tuf.exceptions.DownloadLengthMismatchError(required_length, total_downloaded) else: # We specifically disabled strict checking of required length, but we diff --git a/tuf/formats.py b/tuf/formats.py index cc63a43c..9f8c6d2f 100755 --- a/tuf/formats.py +++ b/tuf/formats.py @@ -465,7 +465,7 @@ class MetaFile(object): between Metadata File objects. """ - info = None + info = {} def __eq__(self, other): return isinstance(other, MetaFile) and self.info == other.info diff --git a/tuf/log.py b/tuf/log.py index a63c71b7..a8dfbdfe 100755 --- a/tuf/log.py +++ b/tuf/log.py @@ -82,7 +82,8 @@ # Set the format for logging messages. # Example format for '_FORMAT_STRING': -# [2013-08-13 15:21:18,068 localtime] [tuf] [INFO][_update_metadata:851@updater.py] +# [2013-08-13 15:21:18,068 localtime] [tuf] +# [INFO][_update_metadata:851@updater.py] _FORMAT_STRING = '[%(asctime)s UTC] [%(name)s] [%(levelname)s] '+\ '[%(funcName)s:%(lineno)s@%(filename)s]\n%(message)s\n'