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


Python header.make_header方法代码示例

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


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

示例1: test_rfc2047_multiline

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_rfc2047_multiline(self):
        eq = self.assertEqual
        s = """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?="""
        dh = decode_header(s)
        eq(dh, [
            (b'Re: ', None),
            (b'r\x8aksm\x9arg\x8cs', 'mac-iceland'),
            (b' baz foo bar ', None),
            (b'r\x8aksm\x9arg\x8cs', 'mac-iceland')])
        header = make_header(dh)
        eq(str(header),
           'Re: r\xe4ksm\xf6rg\xe5s baz foo bar r\xe4ksm\xf6rg\xe5s')
        self.ndiffAssertEqual(header.encode(maxlinelen=76), """\
Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=""") 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:18,代码来源:test_email.py

示例2: test_rfc2047_multiline

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_rfc2047_multiline(self):
        eq = self.assertEqual
        s = """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?="""
        dh = decode_header(s)
        eq(dh, [
            ('Re:', None),
            ('r\x8aksm\x9arg\x8cs', 'mac-iceland'),
            ('baz foo bar', None),
            ('r\x8aksm\x9arg\x8cs', 'mac-iceland')])
        eq(str(make_header(dh)),
           """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar
 =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=""") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_email_renamed.py

示例3: test_whitespace_eater_unicode

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_eater_unicode(self):
        eq = self.assertEqual
        s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>'
        dh = decode_header(s)
        eq(dh, [('Andr\xe9', 'iso-8859-1'), ('Pirard <pirard@dom.ain>', None)])
        hu = unicode(make_header(dh)).encode('latin-1')
        eq(hu, 'Andr\xe9 Pirard <pirard@dom.ain>') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_email_renamed.py

示例4: test_whitespace_eater_unicode_2

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_eater_unicode_2(self):
        eq = self.assertEqual
        s = 'The =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?='
        dh = decode_header(s)
        eq(dh, [('The', None), ('quick brown fox', 'iso-8859-1'),
                ('jumped over the', None), ('lazy dog', 'iso-8859-1')])
        hu = make_header(dh).__unicode__()
        eq(hu, u'The quick brown fox jumped over the lazy dog') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_email_renamed.py

示例5: test_us_ascii_header

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_us_ascii_header(self):
        eq = self.assertEqual
        s = 'hello'
        x = decode_header(s)
        eq(x, [('hello', None)])
        h = make_header(x)
        eq(s, h.encode()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_email_renamed.py

示例6: test_whitespace_eater

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_eater(self):
        eq = self.assertEqual
        s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.'
        parts = decode_header(s)
        eq(parts, [('Subject:', None), ('\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), ('zz.', None)])
        hdr = make_header(parts)
        eq(hdr.encode(),
           'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_email_renamed.py

示例7: test_whitespace_keeper_unicode

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_keeper_unicode(self):
        eq = self.assertEqual
        s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>'
        dh = decode_header(s)
        eq(dh, [(b'Andr\xe9', 'iso-8859-1'),
                (b' Pirard <pirard@dom.ain>', None)])
        header = str(make_header(dh))
        eq(header, 'Andr\xe9 Pirard <pirard@dom.ain>') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_email.py

示例8: test_whitespace_keeper_unicode_2

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_keeper_unicode_2(self):
        eq = self.assertEqual
        s = 'The =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?='
        dh = decode_header(s)
        eq(dh, [(b'The ', None), (b'quick brown fox', 'iso-8859-1'),
                (b' jumped over the ', None), (b'lazy dog', 'iso-8859-1')])
        hu = str(make_header(dh))
        eq(hu, 'The quick brown fox jumped over the lazy dog') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_email.py

示例9: test_rfc2047_rfc2047_7

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_rfc2047_rfc2047_7(self):
        # 7th testcase at end of rfc2047
        s = '(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)'
        self.assertEqual(decode_header(s),
            [(b'(', None), (b'a', 'iso-8859-1'), (b' b', 'iso-8859-2'),
             (b')', None)])
        self.assertEqual(make_header(decode_header(s)).encode(), s.lower())
        self.assertEqual(str(make_header(decode_header(s))), '(a b)') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_email.py

示例10: test_multiline_header

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_multiline_header(self):
        s = '=?windows-1252?q?=22M=FCller_T=22?=\r\n <T.Mueller@xxx.com>'
        self.assertEqual(decode_header(s),
            [(b'"M\xfcller T"', 'windows-1252'),
             (b'<T.Mueller@xxx.com>', None)])
        self.assertEqual(make_header(decode_header(s)).encode(),
                         ''.join(s.splitlines()))
        self.assertEqual(str(make_header(decode_header(s))),
                         '"Müller T" <T.Mueller@xxx.com>')


# Test the MIMEMessage class 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:14,代码来源:test_email.py

示例11: test_make_header_handles_binary_unknown8bit

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_make_header_handles_binary_unknown8bit(self):
        x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
        h = Header(x, charset=email.charset.UNKNOWN8BIT)
        h2 = email.header.make_header(email.header.decode_header(h))
        self.assertEqual(str(h2),
                        'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
        self.assertEqual(email.header.decode_header(h2), [(x, 'unknown-8bit')]) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:9,代码来源:test_email.py

示例12: test_encoded_adjacent_nonencoded

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_encoded_adjacent_nonencoded(self):
        eq = self.assertEqual
        h = Header()
        h.append('hello', 'iso-8859-1')
        h.append('world')
        s = h.encode()
        eq(s, '=?iso-8859-1?q?hello?= world')
        h = make_header(decode_header(s))
        eq(h.encode(), s) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_email.py

示例13: test_whitespace_keeper

# 需要导入模块: from email import header [as 别名]
# 或者: from email.header import make_header [as 别名]
def test_whitespace_keeper(self):
        eq = self.assertEqual
        s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.'
        parts = decode_header(s)
        eq(parts, [(b'Subject: ', None), (b'\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), (b' zz.', None)])
        hdr = make_header(parts)
        eq(hdr.encode(),
           'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_email.py


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