當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。