Make cosmetic changes

Move comment around, and do not use 'message' variable to hold exception message
This commit is contained in:
Vladimir Diaz 2016-11-03 09:58:39 -04:00
parent 455496a36a
commit c1e07e7049

View file

@ -1084,10 +1084,9 @@ def _get_metadata_file(self, metadata_role, remote_filename,
# Verify that the downloaded version matches the version expected by
# the caller.
if version_downloaded != expected_version:
message = \
'Downloaded version number: ' + repr(version_downloaded) + '.' \
' Version number MUST be: ' + repr(expected_version)
raise tuf.BadVersionNumberError(message)
raise tuf.BadVersionNumberError('Downloaded version number: ' +
repr(version_downloaded) + '. Version number MUST be: '
+ repr(expected_version))
# The caller does not know which version to download. Verify that the
# downloaded version is at least greater than the one locally available.
@ -1147,9 +1146,6 @@ def _verify_root_chain_link(self, role, current, next):
# TODO: Instead of the more fragile 'download_safely' switch, unroll the
# function into two separate ones: one for "safe" download, and the other one
# for "unsafe" download? This should induce safer and more readable code.
def _get_file(self, filepath, verify_file_function, file_type,
file_length, compression=None,
verify_compressed_file_function=None, download_safely=True):
@ -1204,7 +1200,7 @@ def _get_file(self, filepath, verify_file_function, file_type,
<Returns>
A 'tuf.util.TempFile' file-like object containing the metadata or target.
"""
file_mirrors = tuf.mirrors.get_list_of_mirrors(file_type, filepath,
self.mirrors)
# file_mirror (URL): error (Exception)
@ -1213,6 +1209,9 @@ def _get_file(self, filepath, verify_file_function, file_type,
for file_mirror in file_mirrors:
try:
# TODO: Instead of the more fragile 'download_safely' switch, unroll the
# function into two separate ones: one for "safe" download, and the other one
# for "unsafe" download? This should induce safer and more readable code.
if download_safely:
file_object = tuf.download.safe_download(file_mirror,
file_length)
@ -2081,11 +2080,11 @@ def _refresh_targets_metadata(self, rolename='targets',
for role in six.iterkeys(self.metadata['current']['snapshot']['meta']):
# snapshot.json keeps track of root.json, targets.json, and delegated
# roles (e.g., django.json, unclaimed.json).
# Remove the 'targets' role because it gets updated when the targets.json
# file is updated in _update_metadata_if_changed('targets') and root.
# roles (e.g., django.json, unclaimed.json). Remove the 'targets' role
# because it gets updated when the targets.json file is updated in
# _update_metadata_if_changed('targets') and root.
if role.endswith('.json'):
role = role[:-len('.json')]
role = role[:-len('.json')]
if role not in ['root', 'targets', rolename]:
roles_to_update.append(role)