def wrap_string(s, max_len, delimiter='.', wrap='[...]', mode='end'):
    """Wrap a string into a given length

    Args:
        s (str): input string
        max_len (int): maximum string length
        delimiter (str, optional): character used for delimiting information categories
        wrap (str, optional): wrapping sequence used
        mode (str, optional): wrapping mode
    Returns:
        str: wrapped string
    """
    if len(s) <= max_len or mode is None:
        return s
    if mode == 'end':
        return s[:max_len - len(wrap)] + wrap
    elif mode == 'mid':
        final_part = s.rpartition(delimiter)[-1]
        wrapped_end = f'{wrap}.{final_part}'
        return s[:max_len - len(wrapped_end)] + wrapped_end
    else:
        raise ValueError('received an unexpected value of argument `mode`')
