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