code: def _size_fmt(num):
      '''
      Format bytes as human-readable file sizes
      '''
      try:
          num = int(num)
          if num < 1024:
              return '{0} bytes'.format(num)
          num /= 1024.0
          for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
              if num < 1024.0:
                  return '{0:3.1f} {1}'.format(num, unit)
              num /= 1024.0
      except Exception:
          log.error('Unable to format file size for \'%s\'', num)
          return 'unknownf _size_fmt(num):
      '''
      Format bytes as human-readable file sizes
      '''
      try:
          num = int(num)
          if num < 1024:
              return '{0} bytes'.format(num)
          num /= 1024.0
          for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
              if num < 1024.0:
                  return '{0:3.1f} {1}'.format(num, unit)
              num /= 1024.0
      except Exception:
          log.error('Unable to format file size for \'%s\'', num)
          return 'unknown'
docs: Format bytes as human-readable file sizes