def truncator(name, chars):
    """Shortens a name to chars and replaces '|' with a comma
    and gets rid of leading and trailing spaces"""
    name = ' '.join(name.split())
    truncated_name = name[:chars] + '...' if len(name) > chars else name
    return truncated_name.replace('|', ', ')
