本文整理汇总了Python中email.Parser.HeaderParser方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.HeaderParser方法的具体用法?Python Parser.HeaderParser怎么用?Python Parser.HeaderParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类email.Parser
的用法示例。
在下文中一共展示了Parser.HeaderParser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_message_rfc822_only
# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import HeaderParser [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)
示例2: test_header_parser
# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import HeaderParser [as 别名]
def test_header_parser(self):
eq = self.assertEqual
# Parse only the headers of a complex multipart MIME document
fp = openfile('msg_02.txt')
try:
msg = HeaderParser().parse(fp)
finally:
fp.close()
eq(msg['from'], 'ppp-request@zzz.org')
eq(msg['to'], 'ppp@zzz.org')
eq(msg.get_content_type(), 'multipart/mixed')
self.assertFalse(msg.is_multipart())
self.assertIsInstance(msg.get_payload(), str)
示例3: test_header_parser
# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import HeaderParser [as 别名]
def test_header_parser(self):
eq = self.assertEqual
# Parse only the headers of a complex multipart MIME document
fp = openfile('msg_02.txt')
try:
msg = HeaderParser().parse(fp)
finally:
fp.close()
eq(msg['from'], 'ppp-request@zzz.org')
eq(msg['to'], 'ppp@zzz.org')
eq(msg.get_content_type(), 'multipart/mixed')
self.assertFalse(msg.is_multipart())
self.assertTrue(isinstance(msg.get_payload(), str))
示例4: test_header_parser
# 需要导入模块: from email import Parser [as 别名]
# 或者: from email.Parser import HeaderParser [as 别名]
def test_header_parser(self):
eq = self.assertEqual
# Parse only the headers of a complex multipart MIME document
fp = openfile('msg_02.txt')
try:
msg = HeaderParser().parse(fp)
finally:
fp.close()
eq(msg['from'], 'ppp-request@zzz.org')
eq(msg['to'], 'ppp@zzz.org')
eq(msg.get_content_type(), 'multipart/mixed')
self.failIf(msg.is_multipart())
self.failUnless(isinstance(msg.get_payload(), str))