def FormatBytesForDisplay(size):
    """Return the size of a file or directory formatted for display."""
    if size in (None, -1, 0):
        return ''
    if size == 1:
        return '1 byte'
    for factor, suffix in ((1 << 30, 'GB'), (1 << 20, 'MB'), (1 << 10, 'kB'
        ), (1, 'bytes')):
        if size >= factor:
            break
    if factor != 1:
        return '%0.1f %s' % (float(size) / factor, suffix)
    return '%d %s' % (size / factor, suffix)
