當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。