import array


def get_text(code_seq, charmap, delims=None):
    """Return a text representation of a string.

    Parameters
    ----------
    code_seq : str
        A string (instance of bytearray).
    charmap : dict
        The character dictionary.
    delims : iterable of str, optional
        The code of the delimiter characters.

    Returns
    -------
    text : str
        A human-readble text, e.g. "ひのきのぼう".
    """
    assert any(
        isinstance(code_seq, i) for i in (bytes, bytearray, array))
    assert isinstance(charmap, dict)
    assert delims is None or any(
        isinstance(code_seq, i) for i in (bytes, bytearray, array))

    if delims and code_seq[-1] in delims:
        code_seq = code_seq[0:-1]

    return ''.join(charmap.get(c, '[{0:02X}]'.format(c))
                   for c in code_seq)