xref: /third_party/python/Doc/library/uu.rst (revision 7db96d56)
17db96d56Sopenharmony_ci:mod:`uu` --- Encode and decode uuencode files
27db96d56Sopenharmony_ci==============================================
37db96d56Sopenharmony_ci
47db96d56Sopenharmony_ci.. module:: uu
57db96d56Sopenharmony_ci   :synopsis: Encode and decode files in uuencode format.
67db96d56Sopenharmony_ci   :deprecated:
77db96d56Sopenharmony_ci
87db96d56Sopenharmony_ci.. moduleauthor:: Lance Ellinghouse
97db96d56Sopenharmony_ci
107db96d56Sopenharmony_ci**Source code:** :source:`Lib/uu.py`
117db96d56Sopenharmony_ci
127db96d56Sopenharmony_ci.. deprecated-removed:: 3.11 3.13
137db96d56Sopenharmony_ci   The :mod:`uu` module is deprecated
147db96d56Sopenharmony_ci   (see :pep:`PEP 594 <594#uu-and-the-uu-encoding>` for details).
157db96d56Sopenharmony_ci   :mod:`base64` is a modern alternative.
167db96d56Sopenharmony_ci
177db96d56Sopenharmony_ci--------------
187db96d56Sopenharmony_ci
197db96d56Sopenharmony_ciThis module encodes and decodes files in uuencode format, allowing arbitrary
207db96d56Sopenharmony_cibinary data to be transferred over ASCII-only connections. Wherever a file
217db96d56Sopenharmony_ciargument is expected, the methods accept a file-like object.  For backwards
227db96d56Sopenharmony_cicompatibility, a string containing a pathname is also accepted, and the
237db96d56Sopenharmony_cicorresponding file will be opened for reading and writing; the pathname ``'-'``
247db96d56Sopenharmony_ciis understood to mean the standard input or output.  However, this interface is
257db96d56Sopenharmony_cideprecated; it's better for the caller to open the file itself, and be sure
267db96d56Sopenharmony_cithat, when required, the mode is ``'rb'`` or ``'wb'`` on Windows.
277db96d56Sopenharmony_ci
287db96d56Sopenharmony_ci.. index::
297db96d56Sopenharmony_ci   single: Jansen, Jack
307db96d56Sopenharmony_ci   single: Ellinghouse, Lance
317db96d56Sopenharmony_ci
327db96d56Sopenharmony_ciThis code was contributed by Lance Ellinghouse, and modified by Jack Jansen.
337db96d56Sopenharmony_ci
347db96d56Sopenharmony_ciThe :mod:`uu` module defines the following functions:
357db96d56Sopenharmony_ci
367db96d56Sopenharmony_ci
377db96d56Sopenharmony_ci.. function:: encode(in_file, out_file, name=None, mode=None, *, backtick=False)
387db96d56Sopenharmony_ci
397db96d56Sopenharmony_ci   Uuencode file *in_file* into file *out_file*.  The uuencoded file will have
407db96d56Sopenharmony_ci   the header specifying *name* and *mode* as the defaults for the results of
417db96d56Sopenharmony_ci   decoding the file. The default defaults are taken from *in_file*, or ``'-'``
427db96d56Sopenharmony_ci   and ``0o666`` respectively.  If *backtick* is true, zeros are represented by
437db96d56Sopenharmony_ci   ``'`'`` instead of spaces.
447db96d56Sopenharmony_ci
457db96d56Sopenharmony_ci   .. versionchanged:: 3.7
467db96d56Sopenharmony_ci      Added the *backtick* parameter.
477db96d56Sopenharmony_ci
487db96d56Sopenharmony_ci
497db96d56Sopenharmony_ci.. function:: decode(in_file, out_file=None, mode=None, quiet=False)
507db96d56Sopenharmony_ci
517db96d56Sopenharmony_ci   This call decodes uuencoded file *in_file* placing the result on file
527db96d56Sopenharmony_ci   *out_file*. If *out_file* is a pathname, *mode* is used to set the permission
537db96d56Sopenharmony_ci   bits if the file must be created. Defaults for *out_file* and *mode* are taken
547db96d56Sopenharmony_ci   from the uuencode header.  However, if the file specified in the header already
557db96d56Sopenharmony_ci   exists, a :exc:`uu.Error` is raised.
567db96d56Sopenharmony_ci
577db96d56Sopenharmony_ci   :func:`decode` may print a warning to standard error if the input was produced
587db96d56Sopenharmony_ci   by an incorrect uuencoder and Python could recover from that error.  Setting
597db96d56Sopenharmony_ci   *quiet* to a true value silences this warning.
607db96d56Sopenharmony_ci
617db96d56Sopenharmony_ci
627db96d56Sopenharmony_ci.. exception:: Error()
637db96d56Sopenharmony_ci
647db96d56Sopenharmony_ci   Subclass of :exc:`Exception`, this can be raised by :func:`uu.decode` under
657db96d56Sopenharmony_ci   various situations, such as described above, but also including a badly
667db96d56Sopenharmony_ci   formatted header, or truncated input file.
677db96d56Sopenharmony_ci
687db96d56Sopenharmony_ci
697db96d56Sopenharmony_ci.. seealso::
707db96d56Sopenharmony_ci
717db96d56Sopenharmony_ci   Module :mod:`binascii`
727db96d56Sopenharmony_ci      Support module containing ASCII-to-binary and binary-to-ASCII conversions.
73