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