def GetPrettyBytes(bytes_num, significant_digits=0):
 byte_prefixes = ['', 'K', 'M', 'G', 'T', 'P', 'E']
 for i in range(0, 7):
  exp = (i * 10)
  if (bytes_num < (1 << (exp + 10))):
   if (i == 0):
    formatted_bytes = str(bytes_num)
   else:
    formatted_bytes = ('%.*f' % (significant_digits, ((bytes_num * 1.0) / (1 << exp))))
   if (formatted_bytes != '1'):
    plural = 's'
   else:
    plural = ''
   return ('%s %sByte%s' % (formatted_bytes, byte_prefixes[i], plural))
 logging.error('Number too high to convert: %d', bytes_num)
 return 'Alot'

def GetPrettyBytes ( bytes_num , significant_digits = 0 ) : byte_prefixes = [ '' , 'K' , 'M' , 'G' , 'T' , 'P' , 'E' ] for i in range ( 0 , 7 ) : exp = ( i * 10 ) if ( bytes_num < ( 1 << ( exp + 10 ) ) ) : if ( i == 0 ) : formatted_bytes = str ( bytes_num ) else : formatted_bytes = ( '%.*f' % ( significant_digits , ( ( bytes_num * 1.0 ) / ( 1 << exp ) ) ) ) if ( formatted_bytes != '1' ) : plural = 's' else : plural = '' return ( '%s %sByte%s' % ( formatted_bytes , byte_prefixes [ i ] , plural ) ) logging . error ( 'Number too high to convert: %d' , bytes_num ) return 'Alot'
get a pretty print view of the given number of bytes .