本文整理汇总了Python中email.iterators.typed_subpart_iterator方法的典型用法代码示例。如果您正苦于以下问题:Python iterators.typed_subpart_iterator方法的具体用法?Python iterators.typed_subpart_iterator怎么用?Python iterators.typed_subpart_iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类email.iterators
的用法示例。
在下文中一共展示了iterators.typed_subpart_iterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_typed_subpart_iterator
# 需要导入模块: from email import iterators [as 别名]
# 或者: from email.iterators import typed_subpart_iterator [as 别名]
def test_typed_subpart_iterator(self):
eq = self.assertEqual
msg = self._msgobj('msg_04.txt')
it = iterators.typed_subpart_iterator(msg, 'text')
lines = []
subparts = 0
for subpart in it:
subparts += 1
lines.append(subpart.get_payload())
eq(subparts, 2)
eq(EMPTYSTRING.join(lines), """\
a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
""")
示例2: test_typed_subpart_iterator_default_type
# 需要导入模块: from email import iterators [as 别名]
# 或者: from email.iterators import typed_subpart_iterator [as 别名]
def test_typed_subpart_iterator_default_type(self):
eq = self.assertEqual
msg = self._msgobj('msg_03.txt')
it = iterators.typed_subpart_iterator(msg, 'text', 'plain')
lines = []
subparts = 0
for subpart in it:
subparts += 1
lines.append(subpart.get_payload())
eq(subparts, 1)
eq(EMPTYSTRING.join(lines), """\
Hi,
Do you like this message?
-Me
""")
示例3: test_alwaysIncludeTimezones
# 需要导入模块: from email import iterators [as 别名]
# 或者: from email.iterators import typed_subpart_iterator [as 别名]
def test_alwaysIncludeTimezones(self):
"""
L{MailHandler.generateEmail} generates a MIME-formatted email with a
text/plain part, a text/html part, and a text/calendar part.
"""
_ignore, message = self.generateSampleEmail(inviteTextWithTimezone)
calparts = tuple(typed_subpart_iterator(message, "text", "calendar"))
self.assertEqual(len(calparts), 1)
caldata = calparts[0].get_payload(decode=True)
self.assertTrue("BEGIN:VTIMEZONE" in caldata)
self.assertTrue("TZID:America/New_York" in caldata)
_ignore, message = self.generateSampleEmail(inviteTextNoTimezone)
calparts = tuple(typed_subpart_iterator(message, "text", "calendar"))
self.assertEqual(len(calparts), 1)
caldata = calparts[0].get_payload(decode=True)
self.assertTrue("BEGIN:VTIMEZONE" in caldata)
self.assertTrue("TZID:America/New_York" in caldata)