Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | |
| 2 | :mod:`macostools` --- Convenience routines for file manipulation |
| 3 | ================================================================ |
| 4 | |
| 5 | .. module:: macostools |
| 6 | :platform: Mac |
| 7 | :synopsis: Convenience routines for file manipulation. |
| 8 | |
| 9 | |
| 10 | This module contains some convenience routines for file-manipulation on the |
| 11 | Macintosh. All file parameters can be specified as pathnames, :class:`FSRef` or |
| 12 | :class:`FSSpec` objects. This module expects a filesystem which supports forked |
| 13 | files, so it should not be used on UFS partitions. |
| 14 | |
| 15 | The :mod:`macostools` module defines the following functions: |
| 16 | |
| 17 | |
| 18 | .. function:: copy(src, dst[, createpath[, copytimes]]) |
| 19 | |
| 20 | Copy file *src* to *dst*. If *createpath* is non-zero the folders leading to |
| 21 | *dst* are created if necessary. The method copies data and resource fork and |
| 22 | some finder information (creator, type, flags) and optionally the creation, |
| 23 | modification and backup times (default is to copy them). Custom icons, comments |
| 24 | and icon position are not copied. |
| 25 | |
| 26 | |
| 27 | .. function:: copytree(src, dst) |
| 28 | |
| 29 | Recursively copy a file tree from *src* to *dst*, creating folders as needed. |
| 30 | *src* and *dst* should be specified as pathnames. |
| 31 | |
| 32 | |
| 33 | .. function:: mkalias(src, dst) |
| 34 | |
| 35 | Create a finder alias *dst* pointing to *src*. |
| 36 | |
| 37 | |
| 38 | .. function:: touched(dst) |
| 39 | |
| 40 | Tell the finder that some bits of finder-information such as creator or type for |
| 41 | file *dst* has changed. The file can be specified by pathname or fsspec. This |
| 42 | call should tell the finder to redraw the files icon. |
| 43 | |
| 44 | .. deprecated:: 2.6 |
| 45 | The function is a no-op on OS X. |
| 46 | |
| 47 | |
| 48 | .. data:: BUFSIZ |
| 49 | |
| 50 | The buffer size for ``copy``, default 1 megabyte. |
| 51 | |
| 52 | Note that the process of creating finder aliases is not specified in the Apple |
| 53 | documentation. Hence, aliases created with :func:`mkalias` could conceivably |
| 54 | have incompatible behaviour in some cases. |
| 55 | |
| 56 | |
| 57 | :mod:`findertools` --- The :program:`finder`'s Apple Events interface |
| 58 | ===================================================================== |
| 59 | |
| 60 | .. module:: findertools |
| 61 | :platform: Mac |
| 62 | :synopsis: Wrappers around the finder's Apple Events interface. |
| 63 | |
| 64 | |
| 65 | .. index:: single: AppleEvents |
| 66 | |
| 67 | This module contains routines that give Python programs access to some |
| 68 | functionality provided by the finder. They are implemented as wrappers around |
| 69 | the AppleEvent interface to the finder. |
| 70 | |
| 71 | All file and folder parameters can be specified either as full pathnames, or as |
| 72 | :class:`FSRef` or :class:`FSSpec` objects. |
| 73 | |
| 74 | The :mod:`findertools` module defines the following functions: |
| 75 | |
| 76 | |
| 77 | .. function:: launch(file) |
| 78 | |
| 79 | Tell the finder to launch *file*. What launching means depends on the file: |
| 80 | applications are started, folders are opened and documents are opened in the |
| 81 | correct application. |
| 82 | |
| 83 | |
| 84 | .. function:: Print(file) |
| 85 | |
| 86 | Tell the finder to print a file. The behaviour is identical to selecting the |
| 87 | file and using the print command in the finder's file menu. |
| 88 | |
| 89 | |
| 90 | .. function:: copy(file, destdir) |
| 91 | |
| 92 | Tell the finder to copy a file or folder *file* to folder *destdir*. The |
| 93 | function returns an :class:`Alias` object pointing to the new file. |
| 94 | |
| 95 | |
| 96 | .. function:: move(file, destdir) |
| 97 | |
| 98 | Tell the finder to move a file or folder *file* to folder *destdir*. The |
| 99 | function returns an :class:`Alias` object pointing to the new file. |
| 100 | |
| 101 | |
| 102 | .. function:: sleep() |
| 103 | |
| 104 | Tell the finder to put the Macintosh to sleep, if your machine supports it. |
| 105 | |
| 106 | |
| 107 | .. function:: restart() |
| 108 | |
| 109 | Tell the finder to perform an orderly restart of the machine. |
| 110 | |
| 111 | |
| 112 | .. function:: shutdown() |
| 113 | |
| 114 | Tell the finder to perform an orderly shutdown of the machine. |
| 115 | |