コード例 #1
1
 def _raw_message_body(self, message):
     content_doc = (yield message.get_wrapper().get_body(self.soledad))
     parser = BodyParser(content_doc.raw, content_type=content_doc.content_type, content_transfer_encoding=content_doc.content_transfer_encoding)
     defer.returnValue(parser.parsed_content())
コード例 #2
0
 def _raw_message_body(self, message):
     content_doc = (yield message.get_wrapper().get_body(self.soledad))
     parser = BodyParser(
         content_doc.raw,
         content_type=content_doc.content_type,
         content_transfer_encoding=content_doc.content_transfer_encoding)
     defer.returnValue(parser.parsed_content())
コード例 #3
0
    def _raw_message_body(self, message):
        content_doc = (yield message.get_wrapper().get_body(self.soledad))
        parser = BodyParser('', content_type='text/plain', content_transfer_encoding='UTF-8')
        # It fix the problem when leap doesn'r found body_phash and returns empty string
        if not isinstance(content_doc, str):
            parser = BodyParser(content_doc.raw, content_type=content_doc.content_type, content_transfer_encoding=content_doc.content_transfer_encoding)

        defer.returnValue(parser.parsed_content())
コード例 #4
0
    def _raw_message_body(self, message):
        content_doc = (yield message.get_wrapper().get_body(self.soledad))
        parser = BodyParser('',
                            content_type='text/plain',
                            content_transfer_encoding='UTF-8')
        # It fix the problem when leap doesn'r found body_phash and returns empty string
        if not isinstance(content_doc, str):
            parser = BodyParser(content_doc.raw,
                                content_type=content_doc.content_type,
                                content_transfer_encoding=content_doc.
                                content_transfer_encoding)

        defer.returnValue(parser.parsed_content())
コード例 #5
0
    def test_body_parser_logs_problems_and_then_ignores_invalid_chars(self, logger_mock):
        data = u'unkown char: \ufffd'
        parser = BodyParser(data, content_type='text/plain; charset=iso-8859-1', content_transfer_encoding='8bit')

        self.assertEqual(u'unkown char: ', parser.parsed_content())
        logger_mock.warn.assert_called_with(u'Failed to encode content for charset iso-8859-1. Ignoring invalid chars: \'latin-1\' codec can\'t encode character u\'\\ufffd\' in position 13: ordinal not in range(256)')
コード例 #6
0
    def test_base64_with_default_us_ascii_encoding(self):
        parser = BodyParser('dGVzdCB0ZXh0\n', content_type='text/plain', content_transfer_encoding='base64')

        self.assertEqual('test text', parser.parsed_content())
コード例 #7
0
    def test_8bit_transfer_encoding_with_iso_8859_1_unicode_input(self):
        data = u'Hmm, here are \xdcml\xe4\xfcts again!'
        parser = BodyParser(data, content_type='text/plain; charset=iso-8859-1', content_transfer_encoding='8bit')

        self.assertEqual(u'Hmm, here are Ümläüts again!', parser.parsed_content())
コード例 #8
0
    def test_base64_text(self):
        parser = BodyParser('dGVzdCB0ZXh0\n', content_type='text/plain; charset="utf-8"', content_transfer_encoding='base64')

        self.assertEqual('test text', parser.parsed_content())
コード例 #9
0
    def test_simple_text(self):
        parser = BodyParser('simple text')

        self.assertEqual('simple text', parser.parsed_content())