当前位置: 首页>>代码示例>>Python>>正文


Python Parser.Parser方法代码示例

本文整理汇总了Python中email.Parser.Parser方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.Parser方法的具体用法?Python Parser.Parser怎么用?Python Parser.Parser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.Parser的用法示例。


在下文中一共展示了Parser.Parser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_empty_multipart_idempotent

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def test_empty_multipart_idempotent(self):
        text = """\
Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY


--BOUNDARY--
"""
        msg = Parser().parsestr(text)
        self.ndiffAssertEqual(text, msg.as_string()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_email.py

示例2: test_boundary_without_trailing_newline

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def test_boundary_without_trailing_newline(self):
        m = Parser().parsestr("""\
Content-Type: multipart/mixed; boundary="===============0012394164=="
MIME-Version: 1.0

--===============0012394164==
Content-Type: image/file1.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64

YXNkZg==
--===============0012394164==--""")
        self.assertEqual(m.get_payload(0).get_payload(), 'YXNkZg==')



# Test some badly formatted messages 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_email.py

示例3: test__all__

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def test__all__(self):
        module = __import__('email')
        all = module.__all__
        all.sort()
        self.assertEqual(all, [
            # Old names
            'Charset', 'Encoders', 'Errors', 'Generator',
            'Header', 'Iterators', 'MIMEAudio', 'MIMEBase',
            'MIMEImage', 'MIMEMessage', 'MIMEMultipart',
            'MIMENonMultipart', 'MIMEText', 'Message',
            'Parser', 'Utils', 'base64MIME',
            # new names
            'base64mime', 'charset', 'encoders', 'errors', 'generator',
            'header', 'iterators', 'message', 'message_from_file',
            'message_from_string', 'mime', 'parser',
            'quopriMIME', 'quoprimime', 'utils',
            ]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_email.py

示例4: _checkModeratorMessage

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def _checkModeratorMessage(self, messageText, sender, moderator, group, postingText):
        p = Parser()
        msg = p.parsestr(messageText)
        headers = dict(msg.items())
        del headers['Message-ID']
        self.assertEqual(
            headers,
            {'From': sender,
             'To': moderator,
             'Subject': 'Moderate new %s message: activities etc' % (group,),
             'Content-Type': 'message/rfc822'})

        posting = p.parsestr(postingText)
        attachment = msg.get_payload()[0]

        for header in ['from', 'to', 'subject', 'message-id', 'newsgroups']:
            self.assertEqual(posting[header], attachment[header])

        self.assertEqual(posting.get_payload(), attachment.get_payload()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_database.py

示例5: _checkModeratorMessage

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def _checkModeratorMessage(self, messageText, sender, moderator, group, postingText):
        p = Parser()
        msg = p.parsestr(messageText)
        headers = dict(msg.items())
        del headers['Message-ID']
        self.assertEquals(
            headers,
            {'From': sender,
             'To': moderator,
             'Subject': 'Moderate new %s message: activities etc' % (group,),
             'Content-Type': 'message/rfc822'})

        posting = p.parsestr(postingText)
        attachment = msg.get_payload()[0]

        for header in ['from', 'to', 'subject', 'message-id', 'newsgroups']:
            self.assertEquals(posting[header], attachment[header])

        self.assertEquals(posting.get_payload(), attachment.get_payload()) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:test_database.py

示例6: test_boundary_without_trailing_newline

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def test_boundary_without_trailing_newline(self):
        m = Parser().parsestr("""\
Content-Type: multipart/mixed; boundary="===============0012394164=="
MIME-Version: 1.0

--===============0012394164==
Content-Type: image/file1.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64

YXNkZg==
--===============0012394164==--""")
        self.assertEquals(m.get_payload(0).get_payload(), 'YXNkZg==')



# Test some badly formatted messages 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:19,代码来源:test_email.py

示例7: test_message_rfc822_only

# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import Parser [as 别名]
def test_message_rfc822_only(self):
        # Issue 7970: message/rfc822 not in multipart parsed by
        # HeaderParser caused an exception when flattened.
        fp = openfile(findfile('msg_46.txt'))
        msgdata = fp.read()
        parser = email.Parser.HeaderParser()
        msg = parser.parsestr(msgdata)
        out = StringIO()
        gen = email.Generator.Generator(out, True, 0)
        gen.flatten(msg, False)
        self.assertEqual(out.getvalue(), msgdata) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_email.py


注:本文中的email.Parser.Parser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。