Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{uu} --- |
Fred Drake | 180b68b | 1999-02-22 13:45:09 +0000 | [diff] [blame] | 2 | Encode and decode uuencode files} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | 180b68b | 1999-02-22 13:45:09 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{uu} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | \modulesynopsis{Encode and decode files in uuencode format.} |
Fred Drake | 180b68b | 1999-02-22 13:45:09 +0000 | [diff] [blame] | 6 | \moduleauthor{Lance Ellinghouse}{} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 7 | |
Fred Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 8 | |
| 9 | This module encodes and decodes files in uuencode format, allowing |
Barry Warsaw | dbfe5e8 | 2001-08-17 20:01:06 +0000 | [diff] [blame] | 10 | arbitrary binary data to be transferred over ASCII-only connections. |
Fred Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 11 | Wherever a file argument is expected, the methods accept a file-like |
| 12 | object. For backwards compatibility, a string containing a pathname |
| 13 | is also accepted, and the corresponding file will be opened for |
| 14 | reading and writing; the pathname \code{'-'} is understood to mean the |
| 15 | standard input or output. However, this interface is deprecated; it's |
| 16 | better for the caller to open the file itself, and be sure that, when |
Martin v. Löwis | 36a4d8c | 2002-10-10 18:24:54 +0000 | [diff] [blame] | 17 | required, the mode is \code{'rb'} or \code{'wb'} on Windows. |
Fred Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 18 | |
| 19 | This code was contributed by Lance Ellinghouse, and modified by Jack |
| 20 | Jansen. |
Fred Drake | 61f45c7 | 1998-04-04 06:31:51 +0000 | [diff] [blame] | 21 | \index{Jansen, Jack} |
| 22 | \index{Ellinghouse, Lance} |
Fred Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 23 | |
| 24 | The \module{uu} module defines the following functions: |
| 25 | |
Fred Drake | 61f45c7 | 1998-04-04 06:31:51 +0000 | [diff] [blame] | 26 | \begin{funcdesc}{encode}{in_file, out_file\optional{, name\optional{, mode}}} |
Barry Warsaw | dbfe5e8 | 2001-08-17 20:01:06 +0000 | [diff] [blame] | 27 | 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 Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 32 | \end{funcdesc} |
| 33 | |
Martin v. Löwis | 9b62b39 | 2005-03-03 10:06:05 +0000 | [diff] [blame] | 34 | \begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode\optional{, quiet}}}} |
Barry Warsaw | dbfe5e8 | 2001-08-17 20:01:06 +0000 | [diff] [blame] | 35 | 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öwis | 9b62b39 | 2005-03-03 10:06:05 +0000 | [diff] [blame] | 41 | |
Fred Drake | b098fd7 | 2005-03-03 17:25:04 +0000 | [diff] [blame] | 42 | \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 Drake | 1aabe5e | 1998-02-19 18:29:18 +0000 | [diff] [blame] | 46 | \end{funcdesc} |
Fred Drake | ae35aa8 | 1999-04-23 15:52:18 +0000 | [diff] [blame] | 47 | |
Barry Warsaw | dbfe5e8 | 2001-08-17 20:01:06 +0000 | [diff] [blame] | 48 | \begin{excclassdesc}{Error}{} |
| 49 | Subclass of \exception{Exception}, this can be raised by |
| 50 | \function{uu.decode()} under various situations, such as described |
Raymond Hettinger | 6880431 | 2005-01-01 00:28:46 +0000 | [diff] [blame] | 51 | above, but also including a badly formatted header, or truncated |
Barry Warsaw | dbfe5e8 | 2001-08-17 20:01:06 +0000 | [diff] [blame] | 52 | input file. |
| 53 | \end{excclassdesc} |
Fred Drake | ae35aa8 | 1999-04-23 15:52:18 +0000 | [diff] [blame] | 54 | |
| 55 | \begin{seealso} |
Fred Drake | ba0a989 | 2000-10-18 17:43:06 +0000 | [diff] [blame] | 56 | \seemodule{binascii}{Support module containing \ASCII-to-binary |
| 57 | and binary-to-\ASCII{} conversions.} |
Fred Drake | ae35aa8 | 1999-04-23 15:52:18 +0000 | [diff] [blame] | 58 | \end{seealso} |