How to use the imapclient.util.assert_imap_protocol function in IMAPClient

To help you get started, we’ve selected a few IMAPClient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mjs / imapclient / tests / test_util_functions.py View on Github external
def test_assert_imap_protocol_with_message(self):
        assert_imap_protocol(True, 'foo')
        with self.assertRaises(ProtocolError):
            assert_imap_protocol(False, 'foo')
github mjs / imapclient / tests / test_util_functions.py View on Github external
def test_assert_imap_protocol(self):
        assert_imap_protocol(True)
        with self.assertRaises(ProtocolError):
            assert_imap_protocol(False)
github mjs / imapclient / tests / test_util_functions.py View on Github external
def test_assert_imap_protocol_with_message(self):
        assert_imap_protocol(True, 'foo')
        with self.assertRaises(ProtocolError):
            assert_imap_protocol(False, 'foo')
github mjs / imapclient / tests / test_util_functions.py View on Github external
def test_assert_imap_protocol(self):
        assert_imap_protocol(True)
        with self.assertRaises(ProtocolError):
            assert_imap_protocol(False)
github mjs / imapclient / imapclient / imapclient.py View on Github external
def _parse_untagged_response(text):
    assert_imap_protocol(text.startswith(b'* '))
    text = text[2:]
    if text.startswith((b'OK ', b'NO ')):
        return tuple(text.split(b' ', 1))
    return parse_response([text])
github mjs / imapclient / imapclient / response_lexer.py View on Github external
def __init__(self, lexer, resp_record):
        self.lexer = lexer
        if isinstance(resp_record, tuple):
            # A 'record' with a string which includes a literal marker, and
            # the literal itself.
            self.src_text = resp_record[0]
            assert_imap_protocol(self.src_text.endswith(b"}"), self.src_text)
            self.literal = resp_record[1]
        else:
            # just a line with no literals.
            self.src_text = resp_record
            self.literal = None
github mjs / imapclient / imapclient / response_lexer.py View on Github external
stream_i.push(nextchar)
                    break    # done skipping over the whitespace

            # Non-whitespace
            token = bytearray()
            for nextchar in stream_i:
                if nextchar in wordchars:
                    token.append(nextchar)
                elif nextchar == OPEN_SQUARE:
                    token.append(nextchar)
                    token.extend(read_until(stream_i, CLOSE_SQUARE, escape=False))
                else:
                    if nextchar in whitespace:
                        yield token
                    elif nextchar == DOUBLE_QUOTE:
                        assert_imap_protocol(not token)
                        token.append(nextchar)
                        token.extend(read_until(stream_i, nextchar))
                        yield token
                    else:
                        # Other punctuation, eg. "(". This ends the current token.
                        if token:
                            yield token
                        yield bytearray([nextchar])
                    break
            else:
                if token:
                    yield token
                break