Module mimetools
[hide private]
[frames] | no frames]

Module mimetools

Various tools used by MIME-reading or MIME-writing programs.

Classes [hide private]
Message
A derived class of rfc822.Message that knows about MIME headers and contains some hooks for decoding encoded and multipart messages.
Functions [hide private]
 
_get_next_counter()
 
choose_boundary()
Return a string usable as a multipart boundary.
 
decode(input, output, encoding)
Decode common content-transfer-encodings (base64, quopri, uuencode).
 
encode(input, output, encoding)
Encode common content-transfer-encodings (base64, quopri, uuencode).
 
pipeto(input, command)
 
pipethrough(input, command, output)
 
copyliteral(input, output)
 
copybinary(input, output)
Variables [hide private]
  _counter_lock = thread.allocate_lock()
  _counter = 0
  _prefix = None
  uudecode_pipe = '(\nTEMP=/tmp/@uu.$$\nsed "s%^begin [0-7][0-7]...
  decodetab = {'base64': 'mmencode -u -b', 'quoted-printable': '...
  encodetab = {'base64': 'mmencode -b', 'quoted-printable': 'mme...

Imports: os, rfc822, tempfile


Function Details [hide private]

choose_boundary()

 

Return a string usable as a multipart boundary.

The string chosen is unique within a single program run, and incorporates the user id (if available), process id (if available), and current time. So it's very unlikely the returned string appears in message text, but there's no guarantee.

The boundary contains dots so you have to quote it in the header.


Variables Details [hide private]

uudecode_pipe

Value:
'''(
TEMP=/tmp/@uu.$$
sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
cat $TEMP
rm $TEMP
)'''

decodetab

Value:
{'base64': 'mmencode -u -b',
 'quoted-printable': 'mmencode -u -q',
 'uue': '''(
TEMP=/tmp/@uu.$$
sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
cat $TEMP
rm $TEMP
)''',
...

encodetab

Value:
{'base64': 'mmencode -b',
 'quoted-printable': 'mmencode -q',
 'uue': 'uuencode tempfile',
 'uuencode': 'uuencode tempfile',
 'x-uue': 'uuencode tempfile',
 'x-uuencode': 'uuencode tempfile'}