def shorten_str(string, length=30, end=10):
    """Shorten a string to the given length."""
    if string is None:
        return ""
    if len(string) <= length:
        return string
    else:
        return "{}...{}".format(string[:length - end], string[- end:])