Back to index

python3.2  3.2.2
Functions | Variables
email.encoders Namespace Reference

Functions

def _qencode
def encode_base64
def encode_quopri
def encode_7or8bit
def encode_noop

Variables

list __all__

Function Documentation

def email.encoders._qencode (   s) [private]

Definition at line 20 of file encoders.py.

00020 
00021 def _qencode(s):
00022     enc = _encodestring(s, quotetabs=True)
00023     # Must encode spaces, which quopri.encodestring() doesn't do
00024     return enc.replace(' ', '=20')
00025 

Here is the caller graph for this function:

Set the Content-Transfer-Encoding header to 7bit or 8bit.

Definition at line 50 of file encoders.py.

00050 
00051 def encode_7or8bit(msg):
00052     """Set the Content-Transfer-Encoding header to 7bit or 8bit."""
00053     orig = msg.get_payload()
00054     if orig is None:
00055         # There's no payload.  For backwards compatibility we use 7bit
00056         msg['Content-Transfer-Encoding'] = '7bit'
00057         return
00058     # We play a trick to make this go fast.  If encoding/decode to ASCII
00059     # succeeds, we know the data must be 7bit, otherwise treat it as 8bit.
00060     try:
00061         if isinstance(orig, str):
00062             orig.encode('ascii')
00063         else:
00064             orig.decode('ascii')
00065     except UnicodeError:
00066         # iso-2022-* is non-ASCII but still 7-bit
00067         charset = msg.get_charset()
00068         output_cset = charset and charset.output_charset
00069         if output_cset and output_cset.lower().startswith('iso-2022-'):
00070             msg['Content-Transfer-Encoding'] = '7bit'
00071         else:
00072             msg['Content-Transfer-Encoding'] = '8bit'
00073     else:
00074         msg['Content-Transfer-Encoding'] = '7bit'
00075 
00076 

Encode the message's payload in Base64.

Also, add an appropriate Content-Transfer-Encoding header.

Definition at line 26 of file encoders.py.

00026 
00027 def encode_base64(msg):
00028     """Encode the message's payload in Base64.
00029 
00030     Also, add an appropriate Content-Transfer-Encoding header.
00031     """
00032     orig = msg.get_payload()
00033     encdata = str(_bencode(orig), 'ascii')
00034     msg.set_payload(encdata)
00035     msg['Content-Transfer-Encoding'] = 'base64'
00036 
00037 


Here is the caller graph for this function:

Do nothing.

Definition at line 77 of file encoders.py.

00077 
00078 def encode_noop(msg):
00079     """Do nothing."""
Encode the message's payload in quoted-printable.

Also, add an appropriate Content-Transfer-Encoding header.

Definition at line 38 of file encoders.py.

00038 
00039 def encode_quopri(msg):
00040     """Encode the message's payload in quoted-printable.
00041 
00042     Also, add an appropriate Content-Transfer-Encoding header.
00043     """
00044     orig = msg.get_payload()
00045     encdata = _qencode(orig)
00046     msg.set_payload(encdata)
00047     msg['Content-Transfer-Encoding'] = 'quoted-printable'
00048 
00049 


Here is the call graph for this function:


Variable Documentation

Initial value:
00001 [
00002     'encode_7or8bit',
00003     'encode_base64',
00004     'encode_noop',
00005     'encode_quopri',
00006     ]

Definition at line 7 of file encoders.py.