def humanize_bytes(num, suffix=u'B', si_prefix=False):
 if (num == 0):
  return (u'0 ' + suffix)
 div = (1000 if si_prefix else 1024)
 exponent = min((int(log(num, div)) if num else 0), (len(unit_list) - 1))
 quotient = (float(num) / (div ** exponent))
 (unit, decimals) = unit_list[exponent]
 if (unit and (not si_prefix)):
  unit = (unit.upper() + u'i')
 return u'{{quotient:.{decimals}f}} {{unit}}{{suffix}}'.format(decimals=decimals).format(quotient=quotient, unit=unit, suffix=suffix)

def humanize_bytes ( num , suffix = u'B' , si_prefix = False ) : if ( num == 0 ) : return ( u'0 ' + suffix ) div = ( 1000 if si_prefix else 1024 ) exponent = min ( ( int ( log ( num , div ) ) if num else 0 ) , ( len ( unit_list ) - 1 ) ) quotient = ( float ( num ) / ( div ** exponent ) ) ( unit , decimals ) = unit_list [ exponent ] if ( unit and ( not si_prefix ) ) : unit = ( unit . upper ( ) + u'i' ) return u'{{quotient:.{decimals}f}} {{unit}}{{suffix}}' . format ( decimals = decimals ) . format ( quotient = quotient , unit = unit , suffix = suffix )
return a humanized string representation of a number of bytes .