Exemple #1
0
def _encode_transfer_encoding(encoding, body):
    if six.PY3:
        if encoding == 'quoted-printable':
            body = quopri.encodestring(body, quotetabs=False)
            body = fix_leading_dot(body)
            return body.decode('utf-8')

        if encoding == 'base64':
            if isinstance(body, six.text_type):
                body = body.encode('utf-8')

            body = _email.encode_base64(body)
            return body.decode('utf-8')

        if six.PY3 and isinstance(body, six.binary_type):
            return body.decode('utf-8')

        return body

    if encoding == 'quoted-printable':
        body = quopri.encodestring(body, quotetabs=False)
        return fix_leading_dot(body)
    elif encoding == 'base64':
        return _email.encode_base64(body)
    else:
        return body
Exemple #2
0
def encode_transfer_encoding(encoding, body):
    if encoding == 'quoted-printable':
        return quopri.encodestring(body, quotetabs=False)
    elif encoding == 'base64':
        return _email.encode_base64(body)
    else:
        return body
Exemple #3
0
def _encode_transfer_encoding(encoding, body):
    if six.PY3:
        if encoding == 'quoted-printable':
            body = quopri.encodestring(body, quotetabs=False)
            return body.decode('utf-8')

        if encoding == 'base64':
            if isinstance(body, six.text_type):
                body = body.encode('utf-8')

            body = _email.encode_base64(body)
            return body.decode('utf-8')

        if six.PY3 and isinstance(body, six.binary_type):
            return body.decode('utf-8')

        return body

    if encoding == 'quoted-printable':
        return quopri.encodestring(body, quotetabs=False)
    elif encoding == 'base64':
        return _email.encode_base64(body)
    else:
        return body