當前位置: 首頁>>代碼示例>>Python>>正文


Python datareader.DataReader類代碼示例

本文整理匯總了Python中slimta.smtp.datareader.DataReader的典型用法代碼示例。如果您正苦於以下問題:Python DataReader類的具體用法?Python DataReader怎麽用?Python DataReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DataReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_return_all

 def test_return_all(self):
     io = IO(None)
     dr = DataReader(io)
     dr.lines = [b'one\r\n', b'two\r\n', b'.\r\n', b'three\r\n']
     dr.EOD = 2
     self.assertEqual(b'one\r\ntwo\r\n', dr.return_all())
     self.assertEqual(b'three\r\n', io.recv_buffer)
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:7,代碼來源:test_slimta_smtp_datareader.py

示例2: _get_message_data

    def _get_message_data(self):
        max_size = self.extensions.getparam('SIZE', filter=int)
        reader = DataReader(self.io, max_size)

        err = None
        timeout = Timeout(self.data_timeout)
        timeout.start()
        try:
            data = reader.recv()
        except ConnectionLost:
            raise
        except SmtpError as e:
            data = None
            err = e
        finally:
            timeout.cancel()

        reply = Reply('250', '2.6.0 Message Accepted for Delivery')
        self._call_custom_handler('HAVE_DATA', reply, data, err)

        self.io.send_reply(reply)
        self.io.flush_send()

        self.have_mailfrom = None
        self.have_rcptto = None
開發者ID:akatrevorjay,項目名稱:python-slimta,代碼行數:25,代碼來源:server.py

示例3: test_return_all

 def test_return_all(self):
     io = IO(None)
     dr = DataReader(io)
     dr.lines = ["one\r\n", "two\r\n", ".\r\n", "three\r\n"]
     dr.EOD = 2
     self.assertEqual("one\r\ntwo\r\n", dr.return_all())
     self.assertEqual("three\r\n", io.recv_buffer)
開發者ID:MichaelEvanchik,項目名稱:python-slimta,代碼行數:7,代碼來源:test_slimta_smtp_datareader.py

示例4: test_recv

 def test_recv(self):
     self.sock.recv(IsA(int)).AndReturn("\r\nthree\r\n")
     self.sock.recv(IsA(int)).AndReturn(".\r\nstuff\r\n")
     self.mox.ReplayAll()
     io = IO(self.sock)
     io.recv_buffer = "one\r\ntwo"
     dr = DataReader(io)
     self.assertEqual("one\r\ntwo\r\nthree\r\n", dr.recv())
開發者ID:MichaelEvanchik,項目名稱:python-slimta,代碼行數:8,代碼來源:test_slimta_smtp_datareader.py

示例5: test_recv

 def test_recv(self):
     self.sock.recv(IsA(int)).AndReturn(b'\r\nthree\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'.\r\nstuff\r\n')
     self.mox.ReplayAll()
     io = IO(self.sock)
     io.recv_buffer = b'one\r\ntwo'
     dr = DataReader(io)
     self.assertEqual(b'one\r\ntwo\r\nthree\r\n', dr.recv())
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:8,代碼來源:test_slimta_smtp_datareader.py

示例6: test_recv_piece

 def test_recv_piece(self):
     self.sock.recv(IsA(int)).AndReturn("one\r\ntwo")
     self.sock.recv(IsA(int)).AndReturn("\r\nthree\r\n.\r\nstuff\r\n")
     self.mox.ReplayAll()
     dr = DataReader(IO(self.sock))
     self.assertTrue(dr.recv_piece())
     self.assertFalse(dr.recv_piece())
     self.assertEqual(["one\r\n", "two\r\n", "three\r\n", ".\r\n", "stuff\r\n", ""], dr.lines)
     self.assertEqual(3, dr.EOD)
     self.assertEqual(5, dr.i)
開發者ID:MichaelEvanchik,項目名稱:python-slimta,代碼行數:10,代碼來源:test_slimta_smtp_datareader.py

示例7: test_recv_piece

 def test_recv_piece(self):
     self.sock.recv(IsA(int)).AndReturn(b'one\r\ntwo')
     self.sock.recv(IsA(int)).AndReturn(b'\r\nthree\r\n.\r\nstuff\r\n')
     self.mox.ReplayAll()
     dr = DataReader(IO(self.sock))
     self.assertTrue(dr.recv_piece())
     self.assertFalse(dr.recv_piece())
     self.assertEqual([b'one\r\n', b'two\r\n', b'three\r\n',
                       b'.\r\n', b'stuff\r\n', b''], dr.lines)
     self.assertEqual(3, dr.EOD)
     self.assertEqual(5, dr.i)
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:11,代碼來源:test_slimta_smtp_datareader.py

示例8: _get_message_data

    def _get_message_data(self):
        max_size = self.extensions.getparam('SIZE', filter=int)
        reader = DataReader(self.io, max_size)

        err = None
        timeout = Timeout(self.data_timeout)
        timeout.start()
        try:
            data = reader.recv()
        except ConnectionLost:
            raise
        except SmtpError, e:
            data = None
            err = e
開發者ID:RoboticCheese,項目名稱:python-slimta,代碼行數:14,代碼來源:server.py

示例9: test_append_line

 def test_append_line(self):
     dr = DataReader(None)
     dr._append_line("asdf")
     dr._append_line("jkl\r\n")
     dr.i += 1
     dr._append_line("qwerty")
     self.assertEqual(["asdfjkl\r\n", "qwerty"], dr.lines)
開發者ID:MichaelEvanchik,項目名稱:python-slimta,代碼行數:7,代碼來源:test_slimta_smtp_datareader.py

示例10: test_append_line

 def test_append_line(self):
     dr = DataReader(None)
     dr._append_line(b'asdf')
     dr._append_line(b'jkl\r\n')
     dr.i += 1
     dr._append_line(b'qwerty')
     self.assertEqual([b'asdfjkl\r\n', b'qwerty'], dr.lines)
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:7,代碼來源:test_slimta_smtp_datareader.py

示例11: test_handle_finished_line_EOD

 def test_handle_finished_line_EOD(self):
     dr = DataReader(None)
     dr.lines = [".\r\n"]
     dr.handle_finished_line()
     assert_equal(0, dr.EOD)
開發者ID:rgcarrasqueira,項目名稱:python-slimta,代碼行數:5,代碼來源:test_slimta_smtp_datareader.py

示例12: test_recv_piece_already_eod

 def test_recv_piece_already_eod(self):
     dr = DataReader(None)
     dr.EOD = 2
     self.assertFalse(dr.recv_piece())
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:4,代碼來源:test_slimta_smtp_datareader.py

示例13: test_from_recv_buffer

 def test_from_recv_buffer(self):
     io = IO(None)
     io.recv_buffer = "test\r\ndata"
     dr = DataReader(io)
     dr.from_recv_buffer()
     self.assertEqual(["test\r\n", "data"], dr.lines)
開發者ID:MichaelEvanchik,項目名稱:python-slimta,代碼行數:6,代碼來源:test_slimta_smtp_datareader.py

示例14: test_add_lines

 def test_add_lines(self):
     dr = DataReader(None)
     dr.add_lines(b'\r\ntwo\r\n.three\r\nfour')
     self.assertEqual([b'\r\n', b'two\r\n', b'three\r\n', b'four'], dr.lines)
     self.assertEqual(3, dr.i)
     self.assertEqual(None, dr.EOD)
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:6,代碼來源:test_slimta_smtp_datareader.py

示例15: test_handle_finished_line_initial_period

 def test_handle_finished_line_initial_period(self):
     dr = DataReader(None)
     dr.lines = [b'..stuff\r\n']
     dr.handle_finished_line()
     self.assertEqual(b'.stuff\r\n', dr.lines[0])
開發者ID:madhugb,項目名稱:python-slimta,代碼行數:5,代碼來源:test_slimta_smtp_datareader.py


注:本文中的slimta.smtp.datareader.DataReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。