def _reporthook(blocknum, blocksize, totalsize):
readsofar = blocknum * blocksize
if totalsize > 0:
percent = min(100, readsofar * 1e2 / totalsize)
s = "\r%5.1f%% %*d / %d" % (
percent, len(str(totalsize)), readsofar, totalsize)
sys.stderr.write(s)
# Near the end
if readsofar >= totalsize:
sys.stderr.write("\n")
# Total size is unknown
else:
sys.stderr.write("\rRead %d" % (readsofar,))
评论列表
文章目录