def cutfill(string, length):
    """ Cutfill formats strings

    If the input string is longer than length, it is trimmed to length-2 adding "..".
    If the input string is shorter than length, it will be padded.

    Args:
        string: String to operate on
        length: Desired length of the output
    Returns:
        The shortened/padded string
    """
    out = (string[:(length-2)] + '..') if len(string) > length else string
    return out.ljust(length)