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