本文整理汇总了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?=""")
示例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>')
示例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')
示例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)])
示例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)])
示例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
示例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)])
示例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())
示例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)
示例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
示例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