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


Python quopri.encodestring方法代码示例

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


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

示例1: add

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def add(self, location: str, content_type: str, payload: str, encoding: str = 'quoted-printable') -> None:
        resource = EmailMessage()
        if content_type == 'text/html':
            resource.add_header('Content-Type', 'text/html', charset='utf-8')
        else:
            resource['Content-Type'] = content_type
        if encoding == 'quoted-printable':
            resource['Content-Transfer-Encoding'] = encoding
            resource.set_payload(quopri.encodestring(payload.encode()))
        elif encoding == 'base64':
            resource['Content-Transfer-Encoding'] = encoding
            resource.set_payload(base64.b64encode(payload))
        elif encoding == 'base64-encoded':  # Already base64 encoded
            resource['Content-Transfer-Encoding'] = 'base64'
            resource.set_payload(payload)
        else:
            raise ValueError('invalid encoding')
        resource['Content-Location'] = location
        self._msg.attach(resource) 
开发者ID:bosondata,项目名称:chrome-prerender,代码行数:21,代码来源:mhtml.py

示例2: _qencode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:6,代码来源:encoders.py

示例3: _encode_quopri_mhtml

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def _encode_quopri_mhtml(msg):
    """Encode the message's payload in quoted-printable.

    Substitute for quopri's default 'encode_quopri' method, which needlessly
    encodes all spaces and tabs, instead of only those at the end on the
    line.

    Args:
        msg: Email message to quote.
    """
    orig = msg.get_payload(decode=True)
    encdata = quopri.encodestring(orig, quotetabs=False)
    msg.set_payload(encdata)
    msg['Content-Transfer-Encoding'] = 'quoted-printable' 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:16,代码来源:mhtml.py

示例4: test_encodestring

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.encodestring(p) == e) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_quopri.py

示例5: test_idempotent_string

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.decodestring(quopri.encodestring(e)) == e) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_quopri.py

示例6: test_embedded_ws

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_embedded_ws(self):
        for p, e in self.ESTRINGS:
            self.assertTrue(quopri.encodestring(p, quotetabs=True) == e)
            self.assertTrue(quopri.decodestring(e) == p) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_quopri.py

示例7: test_encode_header

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_encode_header(self):
        for p, e in self.HSTRINGS:
            self.assertTrue(quopri.encodestring(p, header=True) == e) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_quopri.py

示例8: encode_transfer_encoding

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def encode_transfer_encoding(encoding, body):
    if encoding == 'quoted-printable':
        return quopri.encodestring(body, quotetabs=False)
    elif encoding == 'base64':
        return email.encoders._bencode(body)
    else:
        return body 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:9,代码来源:part.py

示例9: _qencode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(b' ', b'=20') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:encoders.py

示例10: test_encodestring

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assertEqual(quopri.encodestring(p), e) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_quopri.py

示例11: test_idempotent_string

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assertEqual(quopri.decodestring(quopri.encodestring(e)), e) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_quopri.py

示例12: test_embedded_ws

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encodestring [as 别名]
def test_embedded_ws(self):
        for p, e in self.ESTRINGS:
            self.assertEqual(quopri.encodestring(p, quotetabs=True), e)
            self.assertEqual(quopri.decodestring(e), p) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_quopri.py


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