def _size_fmt(num):
 try:
  num = int(num)
  if (num < 1024):
   return '{0} bytes'.format(num)
  num /= 1024.0
  for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
   if (num < 1024.0):
    return '{0:3.1f} {1}'.format(num, unit)
   num /= 1024.0
 except Exception:
  log.error("Unable to format file size for '{0}'".format(num))
  return 'unknown'

def _size_fmt ( num ) : try : num = int ( num ) if ( num < 1024 ) : return '{0} bytes' . format ( num ) num /= 1024.0 for unit in ( 'KiB' , 'MiB' , 'GiB' , 'TiB' , 'PiB' ) : if ( num < 1024.0 ) : return '{0:3.1f} {1}' . format ( num , unit ) num /= 1024.0 except Exception : log . error ( "Unable to format file size for '{0}'" . format ( num ) ) return 'unknown'
format bytes as human-readable file sizes .