printing finesse
This commit is contained in:
@@ -323,17 +323,16 @@ def get_md5(filename,fullfile=False):
|
||||
if fullfile and fsize>DEFAULT_CHUNK:
|
||||
anim_i=0
|
||||
anim_len=len(ANIM)
|
||||
filename_len=len(filename)
|
||||
block_size=2**24
|
||||
chars_per_block=filename_len/(float(fsize)/block_size)
|
||||
percents_per_block=100/(float(fsize)/block_size)
|
||||
md5 = hashlib.md5()
|
||||
with open(filename,'rb') as f:
|
||||
for chunk in iter(lambda: f.read(block_size), b''):
|
||||
sys.stdout.write('\r'+(int(anim_i*chars_per_block)*'_')+ANIM[anim_i%anim_len])
|
||||
sys.stdout.write('\r %s (%02d%%)'%(ANIM[anim_i%anim_len],int(anim_i*percents_per_block)))
|
||||
sys.stdout.flush()
|
||||
anim_i+=1
|
||||
md5.update(chunk)
|
||||
sys.stdout.write('\r'+filename_len*' ')
|
||||
sys.stdout.write('\r ')
|
||||
return md5.hexdigest()
|
||||
return hashlib.md5(open(filename,'rb').read(DEFAULT_CHUNK)).hexdigest()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user