From ffff7f5597c9f40714f5fb494269833efe2191a7 Mon Sep 17 00:00:00 2001 From: Jussi Kukkonen Date: Mon, 5 Jul 2021 10:58:58 +0300 Subject: [PATCH] ngclient: Improve dosctrings and error messages Signed-off-by: Jussi Kukkonen --- tuf/ngclient/_internal/trusted_metadata_set.py | 14 +++++++------- tuf/ngclient/updater.py | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tuf/ngclient/_internal/trusted_metadata_set.py b/tuf/ngclient/_internal/trusted_metadata_set.py index 6a93cc6e87..ff629eff8c 100644 --- a/tuf/ngclient/_internal/trusted_metadata_set.py +++ b/tuf/ngclient/_internal/trusted_metadata_set.py @@ -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}" ) @@ -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): @@ -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 @@ -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): diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index 3e5dcda4ac..75cf229ec0 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -32,7 +32,7 @@ logger = logging.getLogger(__name__) -# Classes + class Updater: """ An implemetation of the TUF client workflow. @@ -79,7 +79,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 @@ -104,8 +104,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 (delegated + targets) metadata required to return the target information. Args: target_path: A target identifier that is a path-relative-URL string