/Doc/library/uu.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 60 lines · 39 code · 21 blank · 0 comment · 0 complexity · 66f494b199a58e3fbfbbe1e89c1d2cd3 MD5 · raw file

  1. :mod:`uu` --- Encode and decode uuencode files
  2. ==============================================
  3. .. module:: uu
  4. :synopsis: Encode and decode files in uuencode format.
  5. .. moduleauthor:: Lance Ellinghouse
  6. This module encodes and decodes files in uuencode format, allowing arbitrary
  7. binary data to be transferred over ASCII-only connections. Wherever a file
  8. argument is expected, the methods accept a file-like object. For backwards
  9. compatibility, a string containing a pathname is also accepted, and the
  10. corresponding file will be opened for reading and writing; the pathname ``'-'``
  11. is understood to mean the standard input or output. However, this interface is
  12. deprecated; it's better for the caller to open the file itself, and be sure
  13. that, when required, the mode is ``'rb'`` or ``'wb'`` on Windows.
  14. .. index::
  15. single: Jansen, Jack
  16. single: Ellinghouse, Lance
  17. This code was contributed by Lance Ellinghouse, and modified by Jack Jansen.
  18. The :mod:`uu` module defines the following functions:
  19. .. function:: encode(in_file, out_file[, name[, mode]])
  20. Uuencode file *in_file* into file *out_file*. The uuencoded file will have the
  21. header specifying *name* and *mode* as the defaults for the results of decoding
  22. the file. The default defaults are taken from *in_file*, or ``'-'`` and ``0666``
  23. respectively.
  24. .. function:: decode(in_file[, out_file[, mode[, quiet]]])
  25. This call decodes uuencoded file *in_file* placing the result on file
  26. *out_file*. If *out_file* is a pathname, *mode* is used to set the permission
  27. bits if the file must be created. Defaults for *out_file* and *mode* are taken
  28. from the uuencode header. However, if the file specified in the header already
  29. exists, a :exc:`uu.Error` is raised.
  30. :func:`decode` may print a warning to standard error if the input was produced
  31. by an incorrect uuencoder and Python could recover from that error. Setting
  32. *quiet* to a true value silences this warning.
  33. .. exception:: Error()
  34. Subclass of :exc:`Exception`, this can be raised by :func:`uu.decode` under
  35. various situations, such as described above, but also including a badly
  36. formatted header, or truncated input file.
  37. .. seealso::
  38. Module :mod:`binascii`
  39. Support module containing ASCII-to-binary and binary-to-ASCII conversions.