本文整理匯總了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)