Skip to content

Commit

Permalink
ngclient: Improve dosctrings and error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
Jussi Kukkonen committed Jul 5, 2021
1 parent 1b404f3 commit d4c310c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions tuf/ngclient/_internal/trusted_metadata_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def update_snapshot(self, data: bytes): # pylint: disable=too-many-branches
!= self.timestamp.signed.meta["snapshot.json"].version
):
raise exceptions.BadVersionNumberError(
f"Expected snapshot version"
f"{self.timestamp.signed.meta['snapshot.json'].version},"
f"Expected snapshot version "
f"{self.timestamp.signed.meta['snapshot.json'].version}, "
f"got {new_snapshot.signed.version}"
)

Expand All @@ -373,8 +373,8 @@ def update_snapshot(self, data: bytes): # pylint: disable=too-many-branches
# Prevent rollback of any metadata versions
if new_fileinfo.version < fileinfo.version:
raise exceptions.BadVersionNumberError(
f"Expected {filename} version"
f"{new_fileinfo.version}, got {fileinfo.version}"
f"Expected {filename} version "
f"{new_fileinfo.version}, got {fileinfo.version}."
)

if new_snapshot.signed.is_expired(self.reference_time):
Expand Down Expand Up @@ -403,7 +403,7 @@ def update_delegated_targets(
Args:
data: unverified new metadata as bytes
role_name: The role name of the new metadata
delegator_name: The name of the role delegating the new metadata
delegator_name: The name of the role delegating to the new metadata
Raises:
RepositoryError: Metadata failed to load or verify. The actual
Expand Down Expand Up @@ -452,8 +452,8 @@ def update_delegated_targets(

if new_delegate.signed.version != meta.version:
raise exceptions.BadVersionNumberError(
f"Expected {role_name} version"
f"{meta.version}, got {new_delegate.signed.version}"
f"Expected {role_name} version "
f"{meta.version}, got {new_delegate.signed.version}."
)

if new_delegate.signed.is_expired(self.reference_time):
Expand Down
7 changes: 3 additions & 4 deletions tuf/ngclient/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

logger = logging.getLogger(__name__)

# Classes
class Updater:
"""
An implemetation of the TUF client workflow.
Expand Down Expand Up @@ -79,7 +78,7 @@ def __init__(
def refresh(self) -> None:
"""
This method downloads, verifies, and loads metadata for the top-level
roles in a specific order (root -> timestamp -> snapshot -> targets)
roles in the specified order (root -> timestamp -> snapshot -> targets)
The expiration time for downloaded metadata is also verified.
The metadata for delegated roles are not refreshed by this method, but
Expand All @@ -104,8 +103,8 @@ def get_one_valid_targetinfo(self, target_path: str) -> Dict:
"""
Returns the target information for a target identified by target_path.
As a side-effect this method downloads all the metadata it needs to
return the target information.
As a side-effect this method downloads all the additional (delegate
targets) metadata required to return the target information.
Args:
target_path: A target identifier that is a path-relative-URL string
Expand Down

0 comments on commit d4c310c

Please sign in to comment.