-
Notifications
You must be signed in to change notification settings - Fork 54
Split up util.get_file_details() #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split up util.get_file_details() #259
Conversation
ef84bba to
76f9385
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch Martin. This looks good to me. I've made some minor suggestions to the docstrings. Let me know what you think.
securesystemslib/util.py
Outdated
| securesystemslib.exceptions.Error: If 'filepath' does not exist. | ||
| <Returns> | ||
| A dictionary conformat to securesystemslib.formats.HASHDICT_SCHEMA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| A dictionary conformat to securesystemslib.formats.HASHDICT_SCHEMA | |
| A dictionary conforming to securesystemslib.formats.HASHDICT_SCHEMA |
securesystemslib/util.py
Outdated
| <Returns> | ||
| A dictionary conformat to securesystemslib.formats.HASHDICT_SCHEMA | ||
| containing information about the hashes of "filepath". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| containing information about the hashes of "filepath". | |
| containing information about the hashes of the file at "filepath". |
securesystemslib/util.py
Outdated
| securesystemslib.exceptions.Error: If 'filepath' does not exist. | ||
| <Returns> | ||
| One digit describing 'filepath' length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| One digit describing 'filepath' length. | |
| The length, in bytes, of the file at 'filepath'. |
securesystemslib/util.py
Outdated
| To get file's hash/hashes information. The hash is computed using the | ||
| sha256 algorithm by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| To get file's hash/hashes information. The hash is computed using the | |
| sha256 algorithm by default. | |
| Compute hash(es) of the file at filepath using each of the specified | |
| hashing algorithms. If no algorithms are specified, the hash is | |
| computed using the SHA-256 algorithm. |
The util.get_file_details() function returns the length and hashes of the specified file. This makes a lot of sense for generating information about TUF targets, where the length and hashes of each target are required, but is potentially too costly function when generating information about TUF metadata files for the snapshot role, where lengths and hashes are optional. Snapshot metadata may only want hashes, or only want lengths, and we don't want to force an adopter to implement their own subset of the functionality in get_file_details(). Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
76f9385 to
f92f1fd
Compare
|
I agree with all of the docstrings suggestions and updated the commit by addressing them. |
Please fill in the fields below to submit a pull request. The more information
that is provided, the better.
Fixes issue #: #246
Description of the changes being introduced by the pull request:
The
util.get_file_details()function returns the length and hashesof the specified file.
As said on issue #246 on first glance it seems that only TUF uses
util.get_file_details()and if that's the case then for TUF it willbe better if we split that function
In the current format the function
util.get_file_details()makes a lot of sense for generating information about TUF targets,
where the length and hashes of each target are required but this is
potentially too costly function when generating information about TUF
metadata files for the snapshot role, where lengths and hashes are optional.
Snapshot metadata may only want hashes, or only want lengths,
and we don't want to force an adopter to implement their own subset
of the functionality in get_file_details().
Please verify and check that the pull request fulfils the following
requirements: