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


Python quopriMIME.encode方法代碼示例

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


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

示例1: test_another_long_almost_unsplittable_header

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_another_long_almost_unsplittable_header(self):
        eq = self.ndiffAssertEqual
        hstr = """\
bug demonstration
\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
\tmore text"""
        h = Header(hstr, continuation_ws='\t')
        eq(h.encode(), """\
bug demonstration
\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
\tmore text""")
        h = Header(hstr)
        eq(h.encode(), """\
bug demonstration
 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
 more text""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:18,代碼來源:test_email.py

示例2: test_encode

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_encode(self):
        eq = self.assertEqual
        eq(base64MIME.encode(''), '')
        eq(base64MIME.encode('hello'), 'aGVsbG8=\n')
        # Test the binary flag
        eq(base64MIME.encode('hello\n'), 'aGVsbG8K\n')
        eq(base64MIME.encode('hello\n', 0), 'aGVsbG8NCg==\n')
        # Test the maxlinelen arg
        eq(base64MIME.encode('xxxx ' * 20, maxlinelen=40), """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
""")
        # Test the eol argument
        eq(base64MIME.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IA==\r
""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:23,代碼來源:test_email.py

示例3: test_long_header_encode

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_long_header_encode(self):
        eq = self.ndiffAssertEqual
        h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
                   'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
                   header_name='X-Foobar-Spoink-Defrobnit')
        eq(h.encode(), '''\
wasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:10,代碼來源:test_email.py

示例4: test_long_header_encode_with_tab_continuation

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_long_header_encode_with_tab_continuation(self):
        eq = self.ndiffAssertEqual
        h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
                   'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
                   header_name='X-Foobar-Spoink-Defrobnit',
                   continuation_ws='\t')
        eq(h.encode(), '''\
wasnipoop; giraffes="very-long-necked-animals";
\tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:11,代碼來源:test_email.py

示例5: test_no_split_long_header

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_no_split_long_header(self):
        eq = self.ndiffAssertEqual
        hstr = 'References: ' + 'x' * 80
        h = Header(hstr, continuation_ws='\t')
        eq(h.encode(), """\
References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:8,代碼來源:test_email.py

示例6: test_splitting_first_line_only_is_long

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_splitting_first_line_only_is_long(self):
        eq = self.ndiffAssertEqual
        hstr = """\
from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
\tby kronos.mems-exchange.org with esmtp (Exim 4.05)
\tid 17k4h5-00034i-00
\tfor [email protected]; Wed, 28 Aug 2002 11:25:20 -0400"""
        h = Header(hstr, maxlinelen=78, header_name='Received',
                   continuation_ws='\t')
        eq(h.encode(), """\
from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
\thelo=cthulhu.gerg.ca)
\tby kronos.mems-exchange.org with esmtp (Exim 4.05)
\tid 17k4h5-00034i-00
\tfor [email protected]; Wed, 28 Aug 2002 11:25:20 -0400""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:17,代碼來源:test_email.py

示例7: test_long_line_after_append

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_long_line_after_append(self):
        eq = self.ndiffAssertEqual
        s = 'This is an example of string which has almost the limit of header length.'
        h = Header(s)
        h.append('Add another line.')
        eq(h.encode(), """\
This is an example of string which has almost the limit of header length.
 Add another line.""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:10,代碼來源:test_email.py

示例8: test_shorter_line_with_append

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_shorter_line_with_append(self):
        eq = self.ndiffAssertEqual
        s = 'This is a shorter line.'
        h = Header(s)
        h.append('Add another sentence. (Surprise?)')
        eq(h.encode(),
           'This is a shorter line. Add another sentence. (Surprise?)') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:9,代碼來源:test_email.py

示例9: test_long_field_name

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_long_field_name(self):
        eq = self.ndiffAssertEqual
        fn = 'X-Very-Very-Very-Long-Header-Name'
        gs = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
        h = Header(gs, 'iso-8859-1', header_name=fn)
        # BAW: this seems broken because the first line is too long
        eq(h.encode(), """\
=?iso-8859-1?q?Die_Mieter_treten_hier_?=
 =?iso-8859-1?q?ein_werden_mit_einem_Foerderband_komfortabel_den_Korridor_?=
 =?iso-8859-1?q?entlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_g?=
 =?iso-8859-1?q?egen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""") 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:13,代碼來源:test_email.py

示例10: test_whitespace_eater_unicode

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_whitespace_eater_unicode(self):
        eq = self.assertEqual
        s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <[email protected]>'
        dh = decode_header(s)
        eq(dh, [('Andr\xe9', 'iso-8859-1'), ('Pirard <[email protected]>', None)])
        hu = unicode(make_header(dh)).encode('latin-1')
        eq(hu, 'Andr\xe9 Pirard <[email protected]>') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:9,代碼來源:test_email.py

示例11: test_simple

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_simple(self):
        eq = self.ndiffAssertEqual
        h = Header('Hello World!')
        eq(h.encode(), 'Hello World!')
        h.append(' Goodbye World!')
        eq(h.encode(), 'Hello World!  Goodbye World!') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:8,代碼來源:test_email.py

示例12: test_simple_surprise

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_simple_surprise(self):
        eq = self.ndiffAssertEqual
        h = Header('Hello World!')
        eq(h.encode(), 'Hello World!')
        h.append('Goodbye World!')
        eq(h.encode(), 'Hello World! Goodbye World!') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:8,代碼來源:test_email.py

示例13: test_long

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_long(self):
        h = Header("I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.",
                   maxlinelen=76)
        for l in h.encode(splitchars=' ').split('\n '):
            self.failUnless(len(l) <= 76) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:7,代碼來源:test_email.py

示例14: test_explicit_maxlinelen

# 需要導入模塊: from email import quopriMIME [as 別名]
# 或者: from email.quopriMIME import encode [as 別名]
def test_explicit_maxlinelen(self):
        eq = self.ndiffAssertEqual
        hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior'
        h = Header(hstr)
        eq(h.encode(), '''\
A very long line that must get split to something other than at the 76th
 character boundary to test the non-default behavior''')
        h = Header(hstr, header_name='Subject')
        eq(h.encode(), '''\
A very long line that must get split to something other than at the
 76th character boundary to test the non-default behavior''')
        h = Header(hstr, maxlinelen=1024, header_name='Subject')
        eq(h.encode(), hstr) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:15,代碼來源:test_email.py

示例15: test_us_ascii_header

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


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