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


Python iterators.typed_subpart_iterator方法代码示例

本文整理汇总了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
""") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_email_renamed.py

示例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
""") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_email_renamed.py

示例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) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:20,代码来源:test_outbound.py


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