Skip to content
Snippets Groups Projects
Commit 825fbbdc authored by David Douard's avatar David Douard
Browse files

Fix rst formatting errors in hashutil.py

Summary: to make sphinx happy.

Test Plan: make -C docs

Reviewers: ardumont

Reviewed By: ardumont

Differential Revision: https://forge.softwareheritage.org/D571
parent 2c1062a5
No related branches found
Tags v0.0.33
No related merge requests found
......@@ -30,25 +30,26 @@ Basic usage examples:
- To compute length, integrate the length to the set of algorithms to
compute, for example:
h = MultiHash(hash_names=set({'length'}).union(DEFAULT_ALGORITHMS))
with open(filepath, 'rb') as f:
h.update(f.read(HASH_BLOCK_SIZE))
hashes = h.digest() # returns a dict of {hash_algo_name: hash_in_bytes}
.. code-block:: python
for chunk in
# then use h as you would
h = MultiHash(hash_names=set({'length'}).union(DEFAULT_ALGORITHMS))
with open(filepath, 'rb') as f:
h.update(f.read(HASH_BLOCK_SIZE))
hashes = h.digest() # returns a dict of {hash_algo_name: hash_in_bytes}
- Write alongside computing hashing algorithms (from a stream), example:
h = MultiHash(length=length)
with open(filepath, 'wb') as f:
for chunk in r.iter_content(): # r a stream of sort
h.update(chunk)
f.write(chunk)
hashes = h.hexdigest() # returns a dict of {hash_algo_name: hash_in_hex}
.. code-block:: python
h = MultiHash(length=length)
with open(filepath, 'wb') as f:
for chunk in r.iter_content(): # r a stream of sort
h.update(chunk)
f.write(chunk)
hashes = h.hexdigest() # returns a dict of {hash_algo_name: hash_in_hex}
Note: Prior to this, we would have to use chunk_cb (cf. hash_file,
hash_path)
Note: Prior to this, we would have to use chunk_cb (cf. hash_file,
hash_path)
This module also defines the following (deprecated) hashing functions:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment