MCPcopy Index your code
hub / github.com/dmlc/dgl / check_sha1

Function check_sha1

python/dgl/data/utils.py:219–244  ·  view source on GitHub ↗

Check whether the sha1 hash of the file content matches the expected hash. Codes borrowed from mxnet/gluon/utils.py Parameters ---------- filename : str Path to the file. sha1_hash : str Expected sha1 hash in hexadecimal digits. Returns ------- bool

(filename, sha1_hash)

Source from the content-addressed store, hash-verified

217
218
219def check_sha1(filename, sha1_hash):
220 """Check whether the sha1 hash of the file content matches the expected hash.
221
222 Codes borrowed from mxnet/gluon/utils.py
223
224 Parameters
225 ----------
226 filename : str
227 Path to the file.
228 sha1_hash : str
229 Expected sha1 hash in hexadecimal digits.
230
231 Returns
232 -------
233 bool
234 Whether the file content matches the expected hash.
235 """
236 sha1 = hashlib.sha1()
237 with open(filename, "rb") as f:
238 while True:
239 data = f.read(1048576)
240 if not data:
241 break
242 sha1.update(data)
243
244 return sha1.hexdigest() == sha1_hash
245
246
247def extract_archive(file, target_dir, overwrite=True):

Callers 3

downloadFunction · 0.70
downloadMethod · 0.70
downloadMethod · 0.70

Calls 2

readMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected