MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / hook

Function hook

tensorpack/utils/fs.py:49–57  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

47 logger.warn("File {} exists. Will overwrite with a new download!".format(filename))
48
49 def hook(t):
50 last_b = [0]
51
52 def inner(b, bsize, tsize=None):
53 if tsize is not None:
54 t.total = tsize
55 t.update((b - last_b[0]) * bsize)
56 last_b[0] = b
57 return inner
58 try:
59 with tqdm.tqdm(unit='B', unit_scale=True, miniters=1, desc=filename) as t:
60 fpath, _ = urllib.request.urlretrieve(url, fpath, reporthook=hook(t))

Callers 1

downloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected