| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`binhex` --- Encode and decode binhex4 files | 
 | 2 | ================================================= | 
 | 3 |  | 
 | 4 | .. module:: binhex | 
 | 5 |    :synopsis: Encode and decode files in binhex4 format. | 
 | 6 |  | 
 | 7 |  | 
 | 8 | This module encodes and decodes files in binhex4 format, a format allowing | 
| Benjamin Peterson | 69a07fb | 2008-05-12 22:25:16 +0000 | [diff] [blame] | 9 | representation of Macintosh files in ASCII. Only the data fork is handled. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 10 |  | 
 | 11 | The :mod:`binhex` module defines the following functions: | 
 | 12 |  | 
 | 13 |  | 
 | 14 | .. function:: binhex(input, output) | 
 | 15 |  | 
 | 16 |    Convert a binary file with filename *input* to binhex file *output*. The | 
 | 17 |    *output* parameter can either be a filename or a file-like object (any object | 
 | 18 |    supporting a :meth:`write` and :meth:`close` method). | 
 | 19 |  | 
 | 20 |  | 
| Georg Brandl | 0d8f073 | 2009-04-05 22:20:44 +0000 | [diff] [blame] | 21 | .. function:: hexbin(input, output) | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 22 |  | 
 | 23 |    Decode a binhex file *input*. *input* may be a filename or a file-like object | 
 | 24 |    supporting :meth:`read` and :meth:`close` methods. The resulting file is written | 
| Georg Brandl | 0d8f073 | 2009-04-05 22:20:44 +0000 | [diff] [blame] | 25 |    to a file named *output*, unless the argument is ``None`` in which case the | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 26 |    output filename is read from the binhex file. | 
 | 27 |  | 
 | 28 | The following exception is also defined: | 
 | 29 |  | 
 | 30 |  | 
 | 31 | .. exception:: Error | 
 | 32 |  | 
 | 33 |    Exception raised when something can't be encoded using the binhex format (for | 
 | 34 |    example, a filename is too long to fit in the filename field), or when input is | 
 | 35 |    not properly encoded binhex data. | 
 | 36 |  | 
 | 37 |  | 
 | 38 | .. seealso:: | 
 | 39 |  | 
 | 40 |    Module :mod:`binascii` | 
 | 41 |       Support module containing ASCII-to-binary and binary-to-ASCII conversions. | 
 | 42 |  | 
 | 43 |  | 
 | 44 | .. _binhex-notes: | 
 | 45 |  | 
 | 46 | Notes | 
 | 47 | ----- | 
 | 48 |  | 
 | 49 | There is an alternative, more powerful interface to the coder and decoder, see | 
 | 50 | the source for details. | 
 | 51 |  | 
 | 52 | If you code or decode textfiles on non-Macintosh platforms they will still use | 
| Georg Brandl | c575c90 | 2008-09-13 17:46:05 +0000 | [diff] [blame] | 53 | the old Macintosh newline convention (carriage-return as end of line). | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 54 |  | 
 | 55 | As of this writing, :func:`hexbin` appears to not work in all cases. | 
 | 56 |  |