blob: 7e546a0d43bc8858d212d5973d260bb7a5d137f1 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{uu} ---
Fred Drake180b68b1999-02-22 13:45:09 +00002 Encode and decode uuencode files}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake180b68b1999-02-22 13:45:09 +00004\declaremodule{standard}{uu}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{Encode and decode files in uuencode format.}
Fred Drake180b68b1999-02-22 13:45:09 +00006\moduleauthor{Lance Ellinghouse}{}
Fred Drakeb91e9341998-07-23 17:59:49 +00007
Fred Drake1aabe5e1998-02-19 18:29:18 +00008
9This module encodes and decodes files in uuencode format, allowing
Barry Warsawdbfe5e82001-08-17 20:01:06 +000010arbitrary binary data to be transferred over ASCII-only connections.
Fred Drake1aabe5e1998-02-19 18:29:18 +000011Wherever a file argument is expected, the methods accept a file-like
12object. For backwards compatibility, a string containing a pathname
13is also accepted, and the corresponding file will be opened for
14reading and writing; the pathname \code{'-'} is understood to mean the
15standard input or output. However, this interface is deprecated; it's
16better for the caller to open the file itself, and be sure that, when
Martin v. Löwis36a4d8c2002-10-10 18:24:54 +000017required, the mode is \code{'rb'} or \code{'wb'} on Windows.
Fred Drake1aabe5e1998-02-19 18:29:18 +000018
19This code was contributed by Lance Ellinghouse, and modified by Jack
20Jansen.
Fred Drake61f45c71998-04-04 06:31:51 +000021\index{Jansen, Jack}
22\index{Ellinghouse, Lance}
Fred Drake1aabe5e1998-02-19 18:29:18 +000023
24The \module{uu} module defines the following functions:
25
Fred Drake61f45c71998-04-04 06:31:51 +000026\begin{funcdesc}{encode}{in_file, out_file\optional{, name\optional{, mode}}}
Barry Warsawdbfe5e82001-08-17 20:01:06 +000027 Uuencode file \var{in_file} into file \var{out_file}. The uuencoded
28 file will have the header specifying \var{name} and \var{mode} as
29 the defaults for the results of decoding the file. The default
30 defaults are taken from \var{in_file}, or \code{'-'} and \code{0666}
31 respectively.
Fred Drake1aabe5e1998-02-19 18:29:18 +000032\end{funcdesc}
33
Martin v. Löwis9b62b392005-03-03 10:06:05 +000034\begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode\optional{, quiet}}}}
Barry Warsawdbfe5e82001-08-17 20:01:06 +000035 This call decodes uuencoded file \var{in_file} placing the result on
36 file \var{out_file}. If \var{out_file} is a pathname, \var{mode} is
37 used to set the permission bits if the file must be
38 created. Defaults for \var{out_file} and \var{mode} are taken from
39 the uuencode header. However, if the file specified in the header
40 already exists, a \exception{uu.Error} is raised.
Martin v. Löwis9b62b392005-03-03 10:06:05 +000041
Fred Drakeb098fd72005-03-03 17:25:04 +000042 \function{decode()} may print a warning to standard error if the
43 input was produced by an incorrect uuencoder and Python could
44 recover from that error. Setting \var{quiet} to a true value
45 silences this warning.
Fred Drake1aabe5e1998-02-19 18:29:18 +000046\end{funcdesc}
Fred Drakeae35aa81999-04-23 15:52:18 +000047
Barry Warsawdbfe5e82001-08-17 20:01:06 +000048\begin{excclassdesc}{Error}{}
49 Subclass of \exception{Exception}, this can be raised by
50 \function{uu.decode()} under various situations, such as described
Raymond Hettinger68804312005-01-01 00:28:46 +000051 above, but also including a badly formatted header, or truncated
Barry Warsawdbfe5e82001-08-17 20:01:06 +000052 input file.
53\end{excclassdesc}
Fred Drakeae35aa81999-04-23 15:52:18 +000054
55\begin{seealso}
Fred Drakeba0a9892000-10-18 17:43:06 +000056 \seemodule{binascii}{Support module containing \ASCII-to-binary
57 and binary-to-\ASCII{} conversions.}
Fred Drakeae35aa81999-04-23 15:52:18 +000058\end{seealso}