def human_readable_filesize(b):
 thresh = 1024.0
 if (b < thresh):
  return '{0:.1f} B'.format(b)
 units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
 u = 0
 b /= thresh
 while (b >= thresh):
  b /= thresh
  u += 1
 return '{0:.1f} {1:s}'.format(round(b, 1), units[u])

def human_readable_filesize ( b ) : thresh = 1024.0 if ( b < thresh ) : return '{0:.1f} B' . format ( b ) units = [ 'KiB' , 'MiB' , 'GiB' , 'TiB' , 'PiB' , 'EiB' , 'ZiB' , 'YiB' ] u = 0 b /= thresh while ( b >= thresh ) : b /= thresh u += 1 return '{0:.1f} {1:s}' . format ( round ( b , 1 ) , units [ u ] )
returns filesize in a human readable format .