def size_str(size):
    """
    size: number of bytes
    Return a human-readable string.
    """
    if size is None:
        return None
    for unit in ('', 'k', 'm', 'g', 't'):
        if size < 100 and size != int(size):
            return '%.1f%s' % (size, unit)
        if size < 1024:
            return '%d%s' % (size, unit)
        size /= 1024.0
