code: def format_size(num, format_str='{num:.1f} {unit}'):
      '''Format the file size into a human readable text.
  
      http://stackoverflow.com/a/1094933/1524507
      '''
      for unit in ('B', 'KiB', 'MiB', 'GiB'):
          if -1024 < num < 1024:
              return format_str.format(num=num, unit=unit)
  
          num /= 1024.0
  
      return format_str.format(num=num, unit='TiB'f format_size(num, format_str='{num:.1f} {unit}'):
      '''Format the file size into a human readable text.
  
      http://stackoverflow.com/a/1094933/1524507
      '''
      for unit in ('B', 'KiB', 'MiB', 'GiB'):
          if -1024 < num < 1024:
              return format_str.format(num=num, unit=unit)
  
          num /= 1024.0
  
      return format_str.format(num=num, unit='TiB')
docs: Format the file size into a human readable text.
  
      http://stackoverflow.com/a/1094933/1524507