blob: 20b4d6c0873718d695b264b8ec3d928785ec4b8c [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +00002
Guido van Rossum4b8c6ea2000-02-04 15:39:30 +00003"""Mimification and unmimification of mail messages.
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +00004
Guido van Rossum54f22ed2000-02-04 15:10:34 +00005Decode quoted-printable parts of a mail message or encode using
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +00006quoted-printable.
7
8Usage:
9 mimify(input, output)
Guido van Rossum74d25e71997-07-30 22:02:28 +000010 unmimify(input, output, decode_base64 = 0)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000011to encode and decode respectively. Input and output may be the name
12of a file or an open file object. Only a readline() method is used
13on the input file, only a write() method is used on the output file.
14When using file names, the input and output file names may be the
15same.
16
17Interactive usage:
18 mimify.py -e [infile [outfile]]
19 mimify.py -d [infile [outfile]]
20to encode and decode respectively. Infile defaults to standard
21input and outfile to standard output.
Guido van Rossum4b8c6ea2000-02-04 15:39:30 +000022"""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000023
24# Configure
25MAXLEN = 200 # if lines longer than this, encode as quoted-printable
26CHARSET = 'ISO-8859-1' # default charset for non-US-ASCII mail
27QUOTE = '> ' # string replies are quoted with
28# End configure
29
Guido van Rossum31626bc1997-10-24 14:46:16 +000030import re, string
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000031
Guido van Rossum31626bc1997-10-24 14:46:16 +000032qp = re.compile('^content-transfer-encoding:\\s*quoted-printable', re.I)
33base64_re = re.compile('^content-transfer-encoding:\\s*base64', re.I)
34mp = re.compile('^content-type:.*multipart/.*boundary="?([^;"\n]*)', re.I|re.S)
35chrset = re.compile('^(content-type:.*charset=")(us-ascii|iso-8859-[0-9]+)(".*)', re.I|re.S)
36he = re.compile('^-*\n')
37mime_code = re.compile('=([0-9a-f][0-9a-f])', re.I)
38mime_head = re.compile('=\\?iso-8859-1\\?q\\?([^? \t\n]+)\\?=', re.I)
39repl = re.compile('^subject:\\s+re: ', re.I)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000040
41class File:
Guido van Rossum54f22ed2000-02-04 15:10:34 +000042 """A simple fake file object that knows about limited read-ahead and
43 boundaries. The only supported method is readline()."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000044
45 def __init__(self, file, boundary):
46 self.file = file
47 self.boundary = boundary
48 self.peek = None
49
50 def readline(self):
51 if self.peek is not None:
52 return ''
53 line = self.file.readline()
54 if not line:
55 return line
56 if self.boundary:
57 if line == self.boundary + '\n':
58 self.peek = line
59 return ''
60 if line == self.boundary + '--\n':
61 self.peek = line
62 return ''
63 return line
64
65class HeaderFile:
66 def __init__(self, file):
67 self.file = file
68 self.peek = None
69
70 def readline(self):
71 if self.peek is not None:
72 line = self.peek
73 self.peek = None
74 else:
75 line = self.file.readline()
76 if not line:
77 return line
Guido van Rossum31626bc1997-10-24 14:46:16 +000078 if he.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000079 return line
80 while 1:
81 self.peek = self.file.readline()
82 if len(self.peek) == 0 or \
83 (self.peek[0] != ' ' and self.peek[0] != '\t'):
84 return line
85 line = line + self.peek
86 self.peek = None
87
88def mime_decode(line):
Guido van Rossum54f22ed2000-02-04 15:10:34 +000089 """Decode a single line of quoted-printable text to 8bit."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000090 newline = ''
Guido van Rossum613418a1997-10-30 15:27:37 +000091 pos = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000092 while 1:
Guido van Rossum613418a1997-10-30 15:27:37 +000093 res = mime_code.search(line, pos)
Guido van Rossum31626bc1997-10-24 14:46:16 +000094 if res is None:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +000095 break
Guido van Rossum613418a1997-10-30 15:27:37 +000096 newline = newline + line[pos:res.start(0)] + \
Guido van Rossum31626bc1997-10-24 14:46:16 +000097 chr(string.atoi(res.group(1), 16))
Guido van Rossum613418a1997-10-30 15:27:37 +000098 pos = res.end(0)
99 return newline + line[pos:]
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000100
101def mime_decode_header(line):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000102 """Decode a header line to 8bit."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000103 newline = ''
Guido van Rossum613418a1997-10-30 15:27:37 +0000104 pos = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000105 while 1:
Guido van Rossum613418a1997-10-30 15:27:37 +0000106 res = mime_head.search(line, pos)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000107 if res is None:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000108 break
Guido van Rossum31626bc1997-10-24 14:46:16 +0000109 match = res.group(1)
Guido van Rossum88bb8081997-08-14 14:10:37 +0000110 # convert underscores to spaces (before =XX conversion!)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000111 match = string.join(string.split(match, '_'), ' ')
Guido van Rossum613418a1997-10-30 15:27:37 +0000112 newline = newline + line[pos:res.start(0)] + mime_decode(match)
113 pos = res.end(0)
114 return newline + line[pos:]
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000115
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000116def unmimify_part(ifile, ofile, decode_base64 = 0):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000117 """Convert a quoted-printable part of a MIME mail message to 8bit."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000118 multipart = None
119 quoted_printable = 0
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000120 is_base64 = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000121 is_repl = 0
122 if ifile.boundary and ifile.boundary[:2] == QUOTE:
123 prefix = QUOTE
124 else:
125 prefix = ''
126
127 # read header
128 hfile = HeaderFile(ifile)
129 while 1:
130 line = hfile.readline()
131 if not line:
132 return
133 if prefix and line[:len(prefix)] == prefix:
134 line = line[len(prefix):]
135 pref = prefix
136 else:
137 pref = ''
138 line = mime_decode_header(line)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000139 if qp.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000140 quoted_printable = 1
141 continue # skip this header
Guido van Rossum31626bc1997-10-24 14:46:16 +0000142 if decode_base64 and base64_re.match(line):
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000143 is_base64 = 1
144 continue
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000145 ofile.write(pref + line)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000146 if not prefix and repl.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000147 # we're dealing with a reply message
148 is_repl = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000149 mp_res = mp.match(line)
150 if mp_res:
151 multipart = '--' + mp_res.group(1)
152 if he.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000153 break
154 if is_repl and (quoted_printable or multipart):
155 is_repl = 0
156
157 # read body
158 while 1:
159 line = ifile.readline()
160 if not line:
161 return
Guido van Rossum31626bc1997-10-24 14:46:16 +0000162 line = re.sub(mime_head, '\\1', line)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000163 if prefix and line[:len(prefix)] == prefix:
164 line = line[len(prefix):]
165 pref = prefix
166 else:
167 pref = ''
168## if is_repl and len(line) >= 4 and line[:4] == QUOTE+'--' and line[-3:] != '--\n':
169## multipart = line[:-1]
170 while multipart:
171 if line == multipart + '--\n':
172 ofile.write(pref + line)
173 multipart = None
174 line = None
175 break
176 if line == multipart + '\n':
177 ofile.write(pref + line)
178 nifile = File(ifile, multipart)
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000179 unmimify_part(nifile, ofile, decode_base64)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000180 line = nifile.peek
Guido van Rossum13452641998-02-27 14:40:38 +0000181 if not line:
182 # premature end of file
183 break
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000184 continue
185 # not a boundary between parts
186 break
187 if line and quoted_printable:
188 while line[-2:] == '=\n':
189 line = line[:-2]
190 newline = ifile.readline()
191 if newline[:len(QUOTE)] == QUOTE:
192 newline = newline[len(QUOTE):]
193 line = line + newline
194 line = mime_decode(line)
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000195 if line and is_base64 and not pref:
196 import base64
197 line = base64.decodestring(line)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000198 if line:
199 ofile.write(pref + line)
200
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000201def unmimify(infile, outfile, decode_base64 = 0):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000202 """Convert quoted-printable parts of a MIME mail message to 8bit."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000203 if type(infile) == type(''):
204 ifile = open(infile)
205 if type(outfile) == type('') and infile == outfile:
206 import os
207 d, f = os.path.split(infile)
208 os.rename(infile, os.path.join(d, ',' + f))
209 else:
210 ifile = infile
211 if type(outfile) == type(''):
212 ofile = open(outfile, 'w')
213 else:
214 ofile = outfile
215 nifile = File(ifile, None)
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000216 unmimify_part(nifile, ofile, decode_base64)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000217 ofile.flush()
218
Guido van Rossum11fbef51997-12-02 17:45:39 +0000219mime_char = re.compile('[=\177-\377]') # quote these chars in body
220mime_header_char = re.compile('[=?\177-\377]') # quote these in header
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000221
222def mime_encode(line, header):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000223 """Code a single line as quoted-printable.
224 If header is set, quote some extra characters."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000225 if header:
226 reg = mime_header_char
227 else:
228 reg = mime_char
229 newline = ''
Guido van Rossum613418a1997-10-30 15:27:37 +0000230 pos = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000231 if len(line) >= 5 and line[:5] == 'From ':
232 # quote 'From ' at the start of a line for stupid mailers
233 newline = string.upper('=%02x' % ord('F'))
Guido van Rossum613418a1997-10-30 15:27:37 +0000234 pos = 1
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000235 while 1:
Guido van Rossum613418a1997-10-30 15:27:37 +0000236 res = reg.search(line, pos)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000237 if res is None:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000238 break
Guido van Rossum613418a1997-10-30 15:27:37 +0000239 newline = newline + line[pos:res.start(0)] + \
240 string.upper('=%02x' % ord(res.group(0)))
241 pos = res.end(0)
242 line = newline + line[pos:]
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000243
244 newline = ''
245 while len(line) >= 75:
246 i = 73
247 while line[i] == '=' or line[i-1] == '=':
248 i = i - 1
249 i = i + 1
250 newline = newline + line[:i] + '=\n'
251 line = line[i:]
252 return newline + line
253
Guido van Rossum11fbef51997-12-02 17:45:39 +0000254mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[\177-\377][-a-zA-Z0-9_+\177-\377]*)([ \t)]|\n)')
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000255
256def mime_encode_header(line):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000257 """Code a single header line as quoted-printable."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000258 newline = ''
Guido van Rossum613418a1997-10-30 15:27:37 +0000259 pos = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000260 while 1:
Guido van Rossum613418a1997-10-30 15:27:37 +0000261 res = mime_header.search(line, pos)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000262 if res is None:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000263 break
Guido van Rossum613418a1997-10-30 15:27:37 +0000264 newline = '%s%s%s=?%s?Q?%s?=%s' % \
265 (newline, line[pos:res.start(0)], res.group(1),
266 CHARSET, mime_encode(res.group(2), 1), res.group(3))
267 pos = res.end(0)
268 return newline + line[pos:]
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000269
Guido van Rossum31626bc1997-10-24 14:46:16 +0000270mv = re.compile('^mime-version:', re.I)
271cte = re.compile('^content-transfer-encoding:', re.I)
Guido van Rossum11fbef51997-12-02 17:45:39 +0000272iso_char = re.compile('[\177-\377]')
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000273
274def mimify_part(ifile, ofile, is_mime):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000275 """Convert an 8bit part of a MIME mail message to quoted-printable."""
Guido van Rossum69155681996-06-10 19:04:02 +0000276 has_cte = is_qp = is_base64 = 0
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000277 multipart = None
278 must_quote_body = must_quote_header = has_iso_chars = 0
279
280 header = []
281 header_end = ''
282 message = []
283 message_end = ''
284 # read header
285 hfile = HeaderFile(ifile)
286 while 1:
287 line = hfile.readline()
288 if not line:
289 break
Guido van Rossum31626bc1997-10-24 14:46:16 +0000290 if not must_quote_header and iso_char.search(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000291 must_quote_header = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000292 if mv.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000293 is_mime = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000294 if cte.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000295 has_cte = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000296 if qp.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000297 is_qp = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000298 elif base64_re.match(line):
Guido van Rossum69155681996-06-10 19:04:02 +0000299 is_base64 = 1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000300 mp_res = mp.match(line)
301 if mp_res:
302 multipart = '--' + mp_res.group(1)
303 if he.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000304 header_end = line
305 break
306 header.append(line)
307
308 # read body
309 while 1:
310 line = ifile.readline()
311 if not line:
312 break
313 if multipart:
314 if line == multipart + '--\n':
315 message_end = line
316 break
317 if line == multipart + '\n':
318 message_end = line
319 break
Guido van Rossum69155681996-06-10 19:04:02 +0000320 if is_base64:
321 message.append(line)
322 continue
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000323 if is_qp:
324 while line[-2:] == '=\n':
325 line = line[:-2]
326 newline = ifile.readline()
327 if newline[:len(QUOTE)] == QUOTE:
328 newline = newline[len(QUOTE):]
329 line = line + newline
330 line = mime_decode(line)
331 message.append(line)
332 if not has_iso_chars:
Guido van Rossum31626bc1997-10-24 14:46:16 +0000333 if iso_char.search(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000334 has_iso_chars = must_quote_body = 1
335 if not must_quote_body:
336 if len(line) > MAXLEN:
337 must_quote_body = 1
338
339 # convert and output header and body
340 for line in header:
341 if must_quote_header:
342 line = mime_encode_header(line)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000343 chrset_res = chrset.match(line)
344 if chrset_res:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000345 if has_iso_chars:
346 # change us-ascii into iso-8859-1
Guido van Rossum31626bc1997-10-24 14:46:16 +0000347 if string.lower(chrset_res.group(2)) == 'us-ascii':
Guido van Rossum613418a1997-10-30 15:27:37 +0000348 line = '%s%s%s' % (chrset_res.group(1),
349 CHARSET,
350 chrset_res.group(3))
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000351 else:
352 # change iso-8859-* into us-ascii
Guido van Rossum613418a1997-10-30 15:27:37 +0000353 line = '%sus-ascii%s' % chrset_res.group(1, 3)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000354 if has_cte and cte.match(line):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000355 line = 'Content-Transfer-Encoding: '
Guido van Rossum69155681996-06-10 19:04:02 +0000356 if is_base64:
357 line = line + 'base64\n'
358 elif must_quote_body:
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000359 line = line + 'quoted-printable\n'
360 else:
361 line = line + '7bit\n'
362 ofile.write(line)
363 if (must_quote_header or must_quote_body) and not is_mime:
364 ofile.write('Mime-Version: 1.0\n')
365 ofile.write('Content-Type: text/plain; ')
366 if has_iso_chars:
367 ofile.write('charset="%s"\n' % CHARSET)
368 else:
369 ofile.write('charset="us-ascii"\n')
370 if must_quote_body and not has_cte:
371 ofile.write('Content-Transfer-Encoding: quoted-printable\n')
372 ofile.write(header_end)
373
374 for line in message:
375 if must_quote_body:
376 line = mime_encode(line, 0)
377 ofile.write(line)
378 ofile.write(message_end)
379
380 line = message_end
381 while multipart:
382 if line == multipart + '--\n':
Guido van Rossumf789ee41997-03-20 14:42:17 +0000383 # read bit after the end of the last part
384 while 1:
385 line = ifile.readline()
386 if not line:
387 return
388 if must_quote_body:
389 line = mime_encode(line, 0)
390 ofile.write(line)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000391 if line == multipart + '\n':
392 nifile = File(ifile, multipart)
393 mimify_part(nifile, ofile, 1)
394 line = nifile.peek
Guido van Rossum13452641998-02-27 14:40:38 +0000395 if not line:
396 # premature end of file
397 break
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000398 ofile.write(line)
399 continue
Guido van Rossum1015be31998-08-07 15:26:56 +0000400 # unexpectedly no multipart separator--copy rest of file
401 while 1:
402 line = ifile.readline()
403 if not line:
404 return
405 if must_quote_body:
406 line = mime_encode(line, 0)
407 ofile.write(line)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000408
409def mimify(infile, outfile):
Guido van Rossum54f22ed2000-02-04 15:10:34 +0000410 """Convert 8bit parts of a MIME mail message to quoted-printable."""
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000411 if type(infile) == type(''):
412 ifile = open(infile)
413 if type(outfile) == type('') and infile == outfile:
414 import os
415 d, f = os.path.split(infile)
416 os.rename(infile, os.path.join(d, ',' + f))
417 else:
418 ifile = infile
419 if type(outfile) == type(''):
420 ofile = open(outfile, 'w')
421 else:
422 ofile = outfile
423 nifile = File(ifile, None)
424 mimify_part(nifile, ofile, 0)
425 ofile.flush()
426
427import sys
428if __name__ == '__main__' or (len(sys.argv) > 0 and sys.argv[0] == 'mimify'):
429 import getopt
430 usage = 'Usage: mimify [-l len] -[ed] [infile [outfile]]'
431
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000432 decode_base64 = 0
433 opts, args = getopt.getopt(sys.argv[1:], 'l:edb')
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000434 if len(args) not in (0, 1, 2):
435 print usage
436 sys.exit(1)
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000437 if (('-e', '') in opts) == (('-d', '') in opts) or \
438 ((('-b', '') in opts) and (('-d', '') not in opts)):
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000439 print usage
440 sys.exit(1)
441 for o, a in opts:
442 if o == '-e':
443 encode = mimify
444 elif o == '-d':
445 encode = unmimify
446 elif o == '-l':
447 try:
448 MAXLEN = string.atoi(a)
449 except:
450 print usage
451 sys.exit(1)
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000452 elif o == '-b':
453 decode_base64 = 1
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000454 if len(args) == 0:
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000455 encode_args = (sys.stdin, sys.stdout)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000456 elif len(args) == 1:
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000457 encode_args = (args[0], sys.stdout)
Sjoerd Mullendere8a0a5c1996-02-14 10:40:03 +0000458 else:
Guido van Rossuma3d9e021997-04-11 15:22:56 +0000459 encode_args = (args[0], args[1])
460 if decode_base64:
461 encode_args = encode_args + (decode_base64,)
462 apply(encode, encode_args)
Guido van Rossum31626bc1997-10-24 14:46:16 +0000463