def splitQuoted(s):
    """Split a string into whitespace delimited tokens

    Tokens that would otherwise be separated but are surrounded by \"
    remain as a single token.  Any token that is not quoted and is
    equal to \"NIL\" is tokenized as C{None}.

    @type s: C{str}
    @param s: The string to be split

    @rtype: C{list} of C{str}
    @return: A list of the resulting tokens

    @raise MismatchedQuoting: Raised if an odd number of quotes are present
    """
    s = s.strip()
    result = []
    word = []
    inQuote = inWord = False
    for i, c in enumerate(s):
        if c == '"':
            if i and s[i-1] == '\\':
                word.pop()
                word.append('"')
            elif not inQuote:
                inQuote = True
            else:
                inQuote = False
                result.append(''.join(word))
                word = []
        elif not inWord and not inQuote and ('"' + string.whitespace) not in c:
            inWord = True
            word.append(c)
        elif inWord and not inQuote and c in string.whitespace:
            w = ''.join(word)
            if w == 'NIL':
                result.append(None)
            else:
                result.append(w)
            word = []
            inWord = False
        elif inWord or inQuote:
            word.append(c)

    if inQuote:
        raise MismatchedQuoting(s)
    if inWord:
        w = ''.join(word)
        if w == 'NIL':
            result.append(None)
        else:
            result.append(w)

    return result
dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/mail/imap4.py/splitQuoted/swapped operands of `not in`