def cap_length(s, char_limit=20, append_ellipsis=True):
    """Makes sure the string doesn't exceed the passed char limit.

    Appends an ellipsis if the string is to long."""
    if len(s) > char_limit:
        if append_ellipsis:
            return s[:char_limit - 3] + '...'
        else:
            return s[:char_limit]
    else:
        return s
