本文整理汇总了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)
示例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
示例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)
示例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())
示例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())
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例12: test_recv_piece_already_eod
def test_recv_piece_already_eod(self):
dr = DataReader(None)
dr.EOD = 2
self.assertFalse(dr.recv_piece())
示例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)
示例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)
示例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])