def humanBitSize(size):
 divisor = 1000
 if (size < divisor):
  return (ngettext('%u bit', '%u bits', size) % size)
 units = [u'Kbit', u'Mbit', u'Gbit', u'Tbit']
 size = float(size)
 for unit in units:
  size = (size / divisor)
  if (size < divisor):
   return ('%.1f %s' % (size, unit))
 return (u'%u %s' % (size, unit))

def humanBitSize ( size ) : divisor = 1000 if ( size < divisor ) : return ( ngettext ( '%u bit' , '%u bits' , size ) % size ) units = [ u'Kbit' , u'Mbit' , u'Gbit' , u'Tbit' ] size = float ( size ) for unit in units : size = ( size / divisor ) if ( size < divisor ) : return ( '%.1f %s' % ( size , unit ) ) return ( u'%u %s' % ( size , unit ) )
convert a size in bit to human classic representation .