Fred Drake | c817e27 | 1998-08-10 18:40:22 +0000 | [diff] [blame] | 1 | \section{\module{macostools} --- |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 2 | Convenience routines for file manipulation} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 3 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{macostools} |
| 5 | \platform{Mac} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 6 | \modulesynopsis{Convenience routines for file manipulation.} |
| 7 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 8 | |
| 9 | This module contains some convenience routines for file-manipulation |
| 10 | on the Macintosh. |
| 11 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 12 | The \module{macostools} module defines the following functions: |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 13 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 14 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 15 | \begin{funcdesc}{copy}{src, dst\optional{, createpath\optional{, copytimes}}} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 16 | Copy file \var{src} to \var{dst}. The files can be specified as |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 17 | pathnames or \pytype{FSSpec} objects. If \var{createpath} is non-zero |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 18 | \var{dst} must be a pathname and the folders leading to the |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 19 | destination are created if necessary. The method copies data and |
| 20 | resource fork and some finder information (creator, type, flags) and |
| 21 | optionally the creation, modification and backup times (default is to |
| 22 | copy them). Custom icons, comments and icon position are not copied. |
| 23 | |
| 24 | If the source is an alias the original to which the alias points is |
| 25 | copied, not the aliasfile. |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 26 | \end{funcdesc} |
| 27 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 28 | \begin{funcdesc}{copytree}{src, dst} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 29 | Recursively copy a file tree from \var{src} to \var{dst}, creating |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 30 | folders as needed. \var{src} and \var{dst} should be specified as |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 31 | pathnames. |
| 32 | \end{funcdesc} |
| 33 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 34 | \begin{funcdesc}{mkalias}{src, dst} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 35 | Create a finder alias \var{dst} pointing to \var{src}. Both may be |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 36 | specified as pathnames or \pytype{FSSpec} objects. |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 37 | \end{funcdesc} |
| 38 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 39 | \begin{funcdesc}{touched}{dst} |
| 40 | Tell the finder that some bits of finder-information such as creator |
| 41 | or type for file \var{dst} has changed. The file can be specified by |
| 42 | pathname or fsspec. This call should prod the finder into redrawing the |
| 43 | files icon. |
| 44 | \end{funcdesc} |
| 45 | |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 46 | \begin{datadesc}{BUFSIZ} |
| 47 | The buffer size for \code{copy}, default 1 megabyte. |
| 48 | \end{datadesc} |
| 49 | |
| 50 | Note that the process of creating finder aliases is not specified in |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 51 | the Apple documentation. Hence, aliases created with \function{mkalias()} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 52 | could conceivably have incompatible behaviour in some cases. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 53 | |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 54 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 55 | \section{\module{findertools} --- |
| 56 | The \program{finder}'s Apple Events interface} |
| 57 | |
| 58 | \declaremodule{standard}{findertools} |
| 59 | \platform{Mac} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 60 | \modulesynopsis{Wrappers around the \program{finder}'s Apple Events interface.} |
| 61 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 62 | |
| 63 | This module contains routines that give Python programs access to some |
| 64 | functionality provided by the finder. They are implemented as wrappers |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 65 | around the AppleEvent\index{AppleEvents} interface to the finder. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 66 | |
| 67 | All file and folder parameters can be specified either as full |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 68 | pathnames or as \pytype{FSSpec} objects. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 69 | |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 70 | The \module{findertools} module defines the following functions: |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 71 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 72 | |
| 73 | \begin{funcdesc}{launch}{file} |
| 74 | Tell the finder to launch \var{file}. What launching means depends on the file: |
| 75 | applications are started, folders are opened and documents are opened |
| 76 | in the correct application. |
| 77 | \end{funcdesc} |
| 78 | |
| 79 | \begin{funcdesc}{Print}{file} |
| 80 | Tell the finder to print a file (again specified by full pathname or |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 81 | \pytype{FSSpec}). The behaviour is identical to selecting the file and using |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 82 | the print command in the finder. |
| 83 | \end{funcdesc} |
| 84 | |
| 85 | \begin{funcdesc}{copy}{file, destdir} |
| 86 | Tell the finder to copy a file or folder \var{file} to folder |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 87 | \var{destdir}. The function returns an \pytype{Alias} object pointing to |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 88 | the new file. |
| 89 | \end{funcdesc} |
| 90 | |
| 91 | \begin{funcdesc}{move}{file, destdir} |
| 92 | Tell the finder to move a file or folder \var{file} to folder |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 93 | \var{destdir}. The function returns an \pytype{Alias} object pointing to |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 94 | the new file. |
| 95 | \end{funcdesc} |
| 96 | |
| 97 | \begin{funcdesc}{sleep}{} |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 98 | Tell the finder to put the Macintosh to sleep, if your machine |
| 99 | supports it. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 100 | \end{funcdesc} |
| 101 | |
| 102 | \begin{funcdesc}{restart}{} |
| 103 | Tell the finder to perform an orderly restart of the machine. |
| 104 | \end{funcdesc} |
| 105 | |
| 106 | \begin{funcdesc}{shutdown}{} |
| 107 | Tell the finder to perform an orderly shutdown of the machine. |
| 108 | \end{funcdesc} |