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


Python base64MIME.encode方法代码示例

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


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

示例1: test_another_long_almost_unsplittable_header

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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 base64MIME [as 别名]
# 或者: from email.base64MIME 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: _authResponse

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME import encode [as 别名]
def _authResponse(self, auth, challenge):
        self._failresponse = self.esmtpAUTHDeclined

        try:
            challenge = base64.decodestring(challenge)
        except binascii.Error, e:
            # Illegal challenge, give up, then quit
            self.sendLine('*')
            self._okresponse = self.esmtpAUTHMalformedChallenge
            self._failresponse = self.esmtpAUTHMalformedChallenge
        else:
            resp = auth.challengeResponse(self.secret, challenge)
            self._expected = [235]
            self._okresponse = self.smtpState_from
            self.sendLine(encode_base64(resp, eol=""))

        if auth.getName() == "LOGIN" and challenge == "Username:":
            self._expected = [334]
            self._authinfo = auth
            self._okresponse = self.esmtpState_challenge 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:22,代码来源:smtp.py

示例4: test_splitting_multiple_long_lines

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME import encode [as 别名]
def test_splitting_multiple_long_lines(self):
        eq = self.ndiffAssertEqual
        hstr = """\
from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <[email protected]>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <[email protected]>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <[email protected]>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
"""
        h = Header(hstr, continuation_ws='\t')
        eq(h.encode(), """\
from babylon.socal-raves.org (localhost [127.0.0.1]);
\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
\tfor <[email protected]>;
\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
\tfor <[email protected]>;
\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
\tfor <[email protected]>;
\tSat, 2 Feb 2002 17:00:06 -0800 (PST)""") 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:23,代码来源:test_email.py

示例5: test_long_header_encode

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例6: test_long_header_encode_with_tab_continuation

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例7: test_no_split_long_header

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例8: test_splitting_first_line_only_is_long

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例9: test_long_line_after_append

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例10: test_shorter_line_with_append

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例11: test_long_field_name

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例12: test_whitespace_eater_unicode

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例13: test_simple

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例14: test_simple_surprise

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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

示例15: test_long

# 需要导入模块: from email import base64MIME [as 别名]
# 或者: from email.base64MIME 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


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