37.3.macostools — Convenience routines for file manipulation

This module contains some convenience routines for file-manipulation on theMacintosh. All file parameters can be specified as pathnames,FSRef orFSSpec objects. This module expects a filesystem which supports forkedfiles, so it should not be used on UFS partitions.

Note

This module has been removed in Python 3.

Themacostools module defines the following functions:

macostools.copy(src,dst[,createpath[,copytimes]])

Copy filesrc todst. Ifcreatepath is non-zero the folders leading todst are created if necessary. The method copies data and resource fork andsome finder information (creator, type, flags) and optionally the creation,modification and backup times (default is to copy them). Custom icons, commentsand icon position are not copied.

Note

This function does not work in 64-bit code because it uses APIs thatare not available in 64-bit mode.

macostools.copytree(src,dst)

Recursively copy a file tree fromsrc todst, creating folders as needed.src anddst should be specified as pathnames.

Note

This function does not work in 64-bit code because it uses APIs thatare not available in 64-bit mode.

macostools.mkalias(src,dst)

Create a finder aliasdst pointing tosrc.

Note

This function does not work in 64-bit code because it uses APIs thatare not available in 64-bit mode.

macostools.touched(dst)

Tell the finder that some bits of finder-information such as creator or type forfiledst has changed. The file can be specified by pathname or fsspec. Thiscall should tell the finder to redraw the files icon.

Deprecated since version 2.6:The function is a no-op on OS X.

macostools.BUFSIZ

The buffer size forcopy, default 1 megabyte.

Note that the process of creating finder aliases is not specified in the Appledocumentation. Hence, aliases created withmkalias() could conceivablyhave incompatible behaviour in some cases.

37.4.findertools — Thefinder’s Apple Events interface

This module contains routines that give Python programs access to somefunctionality provided by the finder. They are implemented as wrappers aroundthe AppleEvent interface to the finder.

All file and folder parameters can be specified either as full pathnames, or asFSRef orFSSpec objects.

Thefindertools module defines the following functions:

findertools.launch(file)

Tell the finder to launchfile. What launching means depends on the file:applications are started, folders are opened and documents are opened in thecorrect application.

findertools.Print(file)

Tell the finder to print a file. The behaviour is identical to selecting thefile and using the print command in the finder’s file menu.

findertools.copy(file,destdir)

Tell the finder to copy a file or folderfile to folderdestdir. Thefunction returns anAlias object pointing to the new file.

findertools.move(file,destdir)

Tell the finder to move a file or folderfile to folderdestdir. Thefunction returns anAlias object pointing to the new file.

findertools.sleep()

Tell the finder to put the Macintosh to sleep, if your machine supports it.

findertools.restart()

Tell the finder to perform an orderly restart of the machine.

findertools.shutdown()

Tell the finder to perform an orderly shutdown of the machine.