當前位置: 首頁>>代碼示例>>Python>>正文


Python Header.decode_header方法代碼示例

本文整理匯總了Python中email.Header.decode_header方法的典型用法代碼示例。如果您正苦於以下問題:Python Header.decode_header方法的具體用法?Python Header.decode_header怎麽用?Python Header.decode_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email.Header的用法示例。


在下文中一共展示了Header.decode_header方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_rfc2047_multiline

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_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.py

示例2: test_whitespace_eater_unicode

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_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.py

示例3: test_whitespace_eater_unicode_2

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_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.py

示例4: test_rfc2047_without_whitespace

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_rfc2047_without_whitespace(self):
        s = 'Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord'
        dh = decode_header(s)
        self.assertEqual(dh, [(s, None)]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_email.py

示例5: test_rfc2047_with_whitespace

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_rfc2047_with_whitespace(self):
        s = 'Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord'
        dh = decode_header(s)
        self.assertEqual(dh, [('Sm', None), ('\xf6', 'iso-8859-1'),
                              ('rg', None), ('\xe5', 'iso-8859-1'),
                              ('sbord', None)]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_email.py

示例6: test_rfc2047_Q_invalid_digits

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_rfc2047_Q_invalid_digits(self):
        # issue 10004.
        s = '=?iso-8859-1?Q?andr=e9=zz?='
        self.assertEqual(decode_header(s),
                        [(b'andr\xe9=zz', 'iso-8859-1')])


# Test the MIMEMessage class 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_email.py

示例7: test_header_needs_no_decoding

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_header_needs_no_decoding(self):
        h = 'no decoding needed'
        self.assertEqual(decode_header(h), [(h, None)]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_email.py

示例8: test_us_ascii_header

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_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.py

示例9: test_encoded_adjacent_nonencoded

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_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,項目名稱:ironpython2,代碼行數:11,代碼來源:test_email.py

示例10: test_broken_base64_header

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_broken_base64_header(self):
        raises = self.assertRaises
        s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
        raises(Errors.HeaderParseError, decode_header, s)

    # Issue 1078919 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_email.py

示例11: test_rfc2047_Q_invalid_digits

# 需要導入模塊: from email import Header [as 別名]
# 或者: from email.Header import decode_header [as 別名]
def test_rfc2047_Q_invalid_digits(self):
        # issue 10004.
        s = '=?iso-8659-1?Q?andr=e9=zz?='
        self.assertEqual(decode_header(s),
                        [(b'andr\xe9=zz', 'iso-8659-1')])


# Test the MIMEMessage class 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:10,代碼來源:test_email.py


注:本文中的email.Header.decode_header方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。