def humanFilesize(size):
 if (size < 10000):
  return (ngettext('%u byte', '%u bytes', size) % size)
 units = [_('KB'), _('MB'), _('GB'), _('TB')]
 size = float(size)
 divisor = 1024
 for unit in units:
  size = (size / divisor)
  if (size < divisor):
   return ('%.1f %s' % (size, unit))
 return ('%u %s' % (size, unit))

def humanFilesize ( size ) : if ( size < 10000 ) : return ( ngettext ( '%u byte' , '%u bytes' , size ) % size ) units = [ _ ( 'KB' ) , _ ( 'MB' ) , _ ( 'GB' ) , _ ( 'TB' ) ] size = float ( size ) divisor = 1024 for unit in units : size = ( size / divisor ) if ( size < divisor ) : return ( '%.1f %s' % ( size , unit ) ) return ( '%u %s' % ( size , unit ) )
convert a file size in byte to human natural representation .