Skip to content

Commit aa3a635

Browse files
committed
Update download_target docstring
Add a detailed documentation of custom_download_handler. Signed-off-by: Teodora Sechkova <[email protected]>
1 parent 641c151 commit aa3a635

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

tuf/client/updater.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,25 +3249,36 @@ def download_target(self, target, destination_directory,
32493249
32503250
custom_download_handler:
32513251
A user provided function performing the actual target file download.
3252-
In order to comply with the TUF specification, the function signature
3253-
should have the form:
3252+
In order to comply with the TUF specification, the function implementation
3253+
should match the following description:
32543254
3255-
'def download_handler_func(url, required_length)'
3255+
def download_handler_func(url, required_length)
3256+
<Purpose>
3257+
Given the 'url' and 'required_length' of the desired file, open a connection
3258+
to 'url', download it, and return the contents of the file. Also ensure
3259+
the length of the downloaded file matches 'required_length' exactly.
32563260
3257-
The function implementation should provide the following functionality:
3261+
<Arguments>
3262+
url:
3263+
A URL string that represents the location of the file.
32583264
3259-
'Given the 'url' and 'required_length' of the desired file, open a
3260-
connection to 'url', download it, and return the contents of the file.
3261-
Also ensure the length of the downloaded file matches 'required_length'
3262-
exactly'
3265+
required_length:
3266+
An integer value representing the length of the file. This is an exact
3267+
limit.
32633268
3264-
Raise 'securesystemslib.exceptions.DownloadLengthMismatchError', if
3265-
STRICT_REQUIRED_LENGTH is True and total_downloaded is not equal
3266-
required_length.
3269+
<Side Effects>
3270+
A temprorary file object is created to store the contents of 'url'.
32673271
3268-
Raise 'tuf.exceptions.SlowRetrievalError', if the total downloaded was
3269-
done in less than the acceptable download speed (as set in
3270-
tuf.settings.py).
3272+
<Exceptions>
3273+
DownloadLengthMismatchError, if there was a
3274+
mismatch of observed vs expected lengths while downloading the file.
3275+
3276+
SlowRetrievalError, if the total downloaded was
3277+
done in less than the acceptable download speed (as set in
3278+
tuf.settings.py).
3279+
3280+
<Returns>
3281+
A temporay file object that points to the contents of 'url'.
32713282
32723283
If None, tuf.download.safe_download is used.
32733284

0 commit comments

Comments
 (0)