def ctcpExtract(message):
    """Extract CTCP data from a string.

    Returns a dictionary with two items:

       - C{'extended'}: a list of CTCP (tag, data) tuples
       - C{'normal'}: a list of strings which were not inside a CTCP delimeter
    """

    extended_messages = []
    normal_messages = []
    retval = {'extended': extended_messages,
              'normal': normal_messages }

    messages = string.split(message, X_DELIM)
    odd = 0

    # X1 extended data X2 nomal data X3 extended data X4 normal...
    while messages:
        if odd:
            extended_messages.append(messages.pop(0))
        else:
            normal_messages.append(messages.pop(0))
        odd = not odd

    extended_messages[:] = filter(None, extended_messages)
    normal_messages[:] = filter(None, normal_messages)

    extended_messages[:] = map(ctcpDequote, extended_messages)
    for i in xrange(len(extended_messages)):
        m = string.split(extended_messages[i], SPC, 1)
        tag = m[0]
        if 1 > len(m):
            data = m[1]
        else:
            data = None

        extended_messages[i] = (tag, data)

    return retval

# CTCP escaping
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/words/protocols/irc.py/ctcpExtract/swapped operands of `>`