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


Python email.feedparser方法代码示例

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


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

示例1: test_push_random

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def test_push_random(self):
        from email.feedparser import BufferedSubFile, NeedMoreData

        n = 10000
        chunksize = 5
        chars = 'abcd \t\r\n'

        s = ''.join(choice(chars) for i in range(n)) + '\n'
        target = s.splitlines(True)

        bsf = BufferedSubFile()
        lines = []
        for i in range(0, len(s), chunksize):
            chunk = s[i:i+chunksize]
            bsf.push(chunk)
            lines.extend(iter(bsf.readline, NeedMoreData))
        self.assertEqual(lines, target) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_email.py

示例2: test_CRLFLF_at_end_of_part

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def test_CRLFLF_at_end_of_part(self):
        # issue 5610: feedparser should not eat two chars from body part ending
        # with "\r\n\n".
        m = (
            "From: foo@bar.com\n"
            "To: baz\n"
            "Mime-Version: 1.0\n"
            "Content-Type: multipart/mixed; boundary=BOUNDARY\n"
            "\n"
            "--BOUNDARY\n"
            "Content-Type: text/plain\n"
            "\n"
            "body ending with CRLF newline\r\n"
            "\n"
            "--BOUNDARY--\n"
          )
        msg = email.message_from_string(m)
        self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_email.py

示例3: test_pushCR_LF

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def test_pushCR_LF(self):
        '''FeedParser BufferedSubFile.push() assumed it received complete
           line endings.  A CR ending one push() followed by a LF starting
           the next push() added an empty line.
        '''
        imt = [
            ("a\r \n",  2),
            ("b",       0),
            ("c\n",     1),
            ("",        0),
            ("d\r\n",   1),
            ("e\r",     0),
            ("\nf",     1),
            ("\r\n",    1),
          ]
        from email.feedparser import BufferedSubFile, NeedMoreData
        bsf = BufferedSubFile()
        om = []
        nt = 0
        for il, n in imt:
            bsf.push(il)
            nt += n
            n1 = 0
            for ol in iter(bsf.readline, NeedMoreData):
                om.append(ol)
                n1 += 1
            self.assertEqual(n, n1)
        self.assertEqual(len(om), nt)
        self.assertEqual(''.join([il for il, n in imt]), ''.join(om)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:test_email.py

示例4: parse

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def parse(self, chunks):
        from email.feedparser import FeedParser
        feedparser = FeedParser()
        for chunk in chunks:
            feedparser.feed(chunk)
        return feedparser.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_email.py

示例5: test_pushCR_LF

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def test_pushCR_LF(self):
        '''FeedParser BufferedSubFile.push() assumed it received complete
           line endings.  A CR ending one push() followed by a LF starting
           the next push() added an empty line.
        '''
        imt = [
            ("a\r \n",  2),
            ("b",       0),
            ("c\n",     1),
            ("",        0),
            ("d\r\n",   1),
            ("e\r",     0),
            ("\nf",     1),
            ("\r\n",    1),
          ]
        from email.feedparser import BufferedSubFile, NeedMoreData
        bsf = BufferedSubFile()
        om = []
        nt = 0
        for il, n in imt:
            bsf.push(il)
            nt += n
            n1 = 0
            while True:
                ol = bsf.readline()
                if ol == NeedMoreData:
                    break
                om.append(ol)
                n1 += 1
            self.assertTrue(n == n1)
        self.assertTrue(len(om) == nt)
        self.assertTrue(''.join([il for il, n in imt]) == ''.join(om)) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:34,代码来源:test_email.py

示例6: test__all__

# 需要导入模块: import email [as 别名]
# 或者: from email import feedparser [as 别名]
def test__all__(self):
        module = __import__('email')
        self.assertEqual(sorted(module.__all__), [
            'base64mime', 'charset', 'encoders', 'errors', 'feedparser',
            'generator', 'header', 'iterators', 'message',
            'message_from_binary_file', 'message_from_bytes',
            'message_from_file', 'message_from_string', 'mime', 'parser',
            'quoprimime', 'utils',
            ]) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_email.py


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