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