def _pretty_size(n):
    """Convert a size in bytes to a human-readable string"""
    if not n:
        return None

    size = int(n)
    shortened = None

    for suffix in ('B', 'KB', 'MB', 'GB', 'TB'):
        if size < 1024:
            shortened = '{} {}'.format(round(size), suffix)
            break

        size /= 1024

    return shortened