Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`uu` --- Encode and decode uuencode files |
| 2 | ============================================== |
| 3 | |
| 4 | .. module:: uu |
| 5 | :synopsis: Encode and decode files in uuencode format. |
| 6 | .. moduleauthor:: Lance Ellinghouse |
| 7 | |
| 8 | |
| 9 | This module encodes and decodes files in uuencode format, allowing arbitrary |
| 10 | binary data to be transferred over ASCII-only connections. Wherever a file |
| 11 | argument is expected, the methods accept a file-like object. For backwards |
| 12 | compatibility, a string containing a pathname is also accepted, and the |
| 13 | corresponding file will be opened for reading and writing; the pathname ``'-'`` |
| 14 | is understood to mean the standard input or output. However, this interface is |
| 15 | deprecated; it's better for the caller to open the file itself, and be sure |
| 16 | that, when required, the mode is ``'rb'`` or ``'wb'`` on Windows. |
| 17 | |
| 18 | .. index:: |
| 19 | single: Jansen, Jack |
| 20 | single: Ellinghouse, Lance |
| 21 | |
| 22 | This code was contributed by Lance Ellinghouse, and modified by Jack Jansen. |
| 23 | |
Éric Araujo | 6e6cb8e | 2010-11-16 19:13:50 +0000 | [diff] [blame] | 24 | .. seealso:: |
| 25 | |
| 26 | Latest version of the :source:`uu module Python source code <Lib/uu.py>` |
| 27 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 28 | The :mod:`uu` module defines the following functions: |
| 29 | |
| 30 | |
Georg Brandl | 7f01a13 | 2009-09-16 15:58:14 +0000 | [diff] [blame] | 31 | .. function:: encode(in_file, out_file, name=None, mode=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 32 | |
Georg Brandl | f4a4123 | 2008-05-26 17:55:52 +0000 | [diff] [blame] | 33 | Uuencode file *in_file* into file *out_file*. The uuencoded file will have |
| 34 | the header specifying *name* and *mode* as the defaults for the results of |
| 35 | decoding the file. The default defaults are taken from *in_file*, or ``'-'`` |
| 36 | and ``0o666`` respectively. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 37 | |
| 38 | |
Georg Brandl | 7f01a13 | 2009-09-16 15:58:14 +0000 | [diff] [blame] | 39 | .. function:: decode(in_file, out_file=None, mode=None, quiet=False) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 40 | |
| 41 | This call decodes uuencoded file *in_file* placing the result on file |
| 42 | *out_file*. If *out_file* is a pathname, *mode* is used to set the permission |
| 43 | bits if the file must be created. Defaults for *out_file* and *mode* are taken |
| 44 | from the uuencode header. However, if the file specified in the header already |
| 45 | exists, a :exc:`uu.Error` is raised. |
| 46 | |
| 47 | :func:`decode` may print a warning to standard error if the input was produced |
| 48 | by an incorrect uuencoder and Python could recover from that error. Setting |
| 49 | *quiet* to a true value silences this warning. |
| 50 | |
| 51 | |
| 52 | .. exception:: Error() |
| 53 | |
| 54 | Subclass of :exc:`Exception`, this can be raised by :func:`uu.decode` under |
| 55 | various situations, such as described above, but also including a badly |
| 56 | formatted header, or truncated input file. |
| 57 | |
| 58 | |
| 59 | .. seealso:: |
| 60 | |
| 61 | Module :mod:`binascii` |
| 62 | Support module containing ASCII-to-binary and binary-to-ASCII conversions. |
| 63 | |