def str_reduce(msg, maxwidth):
    """ Reduce a string with dots (...) if its length is greater than maxwidth """
    if len(msg) >= maxwidth:
        return msg[:maxwidth - 3] + '...'
    else:
        return msg
