Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35bfd3f

Browse files
committed
Created Finder 7.0 AE interface and a test program that uses the
finder to launch an application.
1 parent 6244867 commit 35bfd3f

2 files changed

Lines changed: 343 additions & 0 deletions

File tree

Mac/Lib/test/testfinderopen.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Make the finder open an application, file or folder"""
2+
3+
import Finder_7_0_Suite
4+
import aetools
5+
import MacOS
6+
import sys
7+
import macfs
8+
9+
SIGNATURE='MACS'
10+
11+
class Finder(aetools.TalkTo, Finder_7_0_Suite.Finder_7_0_Suite):
12+
pass
13+
14+
def open_in_finder(file):
15+
"""Open a file thru the finder. Specify file by name or fsspec"""
16+
finder = Finder(SIGNATURE)
17+
fss = macfs.FSSpec(file)
18+
vRefNum, parID, name = fss.as_tuple()
19+
dir_fss = macfs.FSSpec((vRefNum, parID, ''))
20+
file_alias = fss.NewAlias()
21+
dir_alias = dir_fss.NewAlias()
22+
return finder.open(file_alias, items=[file_alias])
23+
24+
def main():
25+
fss, ok = macfs.PromptGetFile('File to launch:')
26+
if not ok: sys.exit(0)
27+
result = open_in_finder(fss)
28+
if result:
29+
print 'Result: ', result
30+
31+
if __name__ == '__main__':
32+
main()
33+
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
"""Suite 7.0 Finder Suite: This is the original Finder suite. These events will be supported in the future, but the syntax may be changed in a future Finder release.
2+
Level 1, version 1
3+
4+
Generated from flap:Systeemmap:Finder
5+
AETE/AEUT resource version 0/149, language 0, script 0
6+
"""
7+
8+
import aetools
9+
import MacOS
10+
11+
_code = 'FNDR'
12+
13+
class Finder_7_0_Suite:
14+
15+
def open_about_box(self, _no_object=None, _attributes={}, **_arguments):
16+
"""open about box: Open the 'About This Mac' window
17+
Keyword argument _attributes: AppleEvent attribute dictionary
18+
"""
19+
_code = 'aevt'
20+
_subcode = 'abou'
21+
22+
if _arguments: raise TypeError, 'No optional args expected'
23+
if _no_object != None: raise TypeError, 'No direct arg expected'
24+
25+
26+
_reply, _arguments, _attributes = self.send(_code, _subcode,
27+
_arguments, _attributes)
28+
if _arguments.has_key('errn'):
29+
raise MacOS.Error, aetools.decodeerror(_arguments)
30+
# XXXX Optionally decode result
31+
if _arguments.has_key('----'):
32+
return _arguments['----']
33+
34+
_argmap_copy_to = {
35+
'_from' : 'fsel',
36+
}
37+
38+
def copy_to(self, _object, _attributes={}, **_arguments):
39+
"""copy to: Copies one or more items into a folder
40+
Required argument: Alias for folder into which the items are copied
41+
Keyword argument _from: List of aliases for items to be copied
42+
Keyword argument _attributes: AppleEvent attribute dictionary
43+
"""
44+
_code = 'FNDR'
45+
_subcode = 'drag'
46+
47+
aetools.keysubst(_arguments, self._argmap_copy_to)
48+
_arguments['----'] = _object
49+
50+
51+
_reply, _arguments, _attributes = self.send(_code, _subcode,
52+
_arguments, _attributes)
53+
if _arguments.has_key('errn'):
54+
raise MacOS.Error, aetools.decodeerror(_arguments)
55+
# XXXX Optionally decode result
56+
if _arguments.has_key('----'):
57+
return _arguments['----']
58+
59+
_argmap_duplicate = {
60+
'items' : 'fsel',
61+
}
62+
63+
def duplicate(self, _object, _attributes={}, **_arguments):
64+
"""duplicate: Duplicate a set of items in a folder
65+
Required argument: Alias for folder containing the items
66+
Keyword argument items: List of aliases for items in the folder
67+
Keyword argument _attributes: AppleEvent attribute dictionary
68+
"""
69+
_code = 'FNDR'
70+
_subcode = 'sdup'
71+
72+
aetools.keysubst(_arguments, self._argmap_duplicate)
73+
_arguments['----'] = _object
74+
75+
76+
_reply, _arguments, _attributes = self.send(_code, _subcode,
77+
_arguments, _attributes)
78+
if _arguments.has_key('errn'):
79+
raise MacOS.Error, aetools.decodeerror(_arguments)
80+
# XXXX Optionally decode result
81+
if _arguments.has_key('----'):
82+
return _arguments['----']
83+
84+
def empty_trash(self, _no_object=None, _attributes={}, **_arguments):
85+
"""empty trash: Empties the trash
86+
Keyword argument _attributes: AppleEvent attribute dictionary
87+
"""
88+
_code = 'FNDR'
89+
_subcode = 'empt'
90+
91+
if _arguments: raise TypeError, 'No optional args expected'
92+
if _no_object != None: raise TypeError, 'No direct arg expected'
93+
94+
95+
_reply, _arguments, _attributes = self.send(_code, _subcode,
96+
_arguments, _attributes)
97+
if _arguments.has_key('errn'):
98+
raise MacOS.Error, aetools.decodeerror(_arguments)
99+
# XXXX Optionally decode result
100+
if _arguments.has_key('----'):
101+
return _arguments['----']
102+
103+
_argmap_make_aliases_for = {
104+
'items' : 'fsel',
105+
}
106+
107+
def make_aliases_for(self, _object, _attributes={}, **_arguments):
108+
"""make aliases for: Make aliases to items from a single folder
109+
Required argument: Alias for folder containing the items
110+
Keyword argument items: List of aliases for items in folder
111+
Keyword argument _attributes: AppleEvent attribute dictionary
112+
"""
113+
_code = 'FNDR'
114+
_subcode = 'sali'
115+
116+
aetools.keysubst(_arguments, self._argmap_make_aliases_for)
117+
_arguments['----'] = _object
118+
119+
120+
_reply, _arguments, _attributes = self.send(_code, _subcode,
121+
_arguments, _attributes)
122+
if _arguments.has_key('errn'):
123+
raise MacOS.Error, aetools.decodeerror(_arguments)
124+
# XXXX Optionally decode result
125+
if _arguments.has_key('----'):
126+
return _arguments['----']
127+
128+
_argmap_move_to = {
129+
'_from' : 'fsel',
130+
}
131+
132+
def move_to(self, _object, _attributes={}, **_arguments):
133+
"""move to: Move one or more items into a folder
134+
Required argument: Alias for destination folder
135+
Keyword argument _from: List of aliases for items to be moved
136+
Keyword argument _attributes: AppleEvent attribute dictionary
137+
"""
138+
_code = 'FNDR'
139+
_subcode = 'move'
140+
141+
aetools.keysubst(_arguments, self._argmap_move_to)
142+
_arguments['----'] = _object
143+
144+
145+
_reply, _arguments, _attributes = self.send(_code, _subcode,
146+
_arguments, _attributes)
147+
if _arguments.has_key('errn'):
148+
raise MacOS.Error, aetools.decodeerror(_arguments)
149+
# XXXX Optionally decode result
150+
if _arguments.has_key('----'):
151+
return _arguments['----']
152+
153+
def sleep(self, _no_object=None, _attributes={}, **_arguments):
154+
"""sleep: Put portable into sleep mode
155+
Keyword argument _attributes: AppleEvent attribute dictionary
156+
"""
157+
_code = 'FNDR'
158+
_subcode = 'slep'
159+
160+
if _arguments: raise TypeError, 'No optional args expected'
161+
if _no_object != None: raise TypeError, 'No direct arg expected'
162+
163+
164+
_reply, _arguments, _attributes = self.send(_code, _subcode,
165+
_arguments, _attributes)
166+
if _arguments.has_key('errn'):
167+
raise MacOS.Error, aetools.decodeerror(_arguments)
168+
# XXXX Optionally decode result
169+
if _arguments.has_key('----'):
170+
return _arguments['----']
171+
172+
def shut_down(self, _no_object=None, _attributes={}, **_arguments):
173+
"""shut down: Shuts down the Macintosh if all applications can quit
174+
Keyword argument _attributes: AppleEvent attribute dictionary
175+
"""
176+
_code = 'FNDR'
177+
_subcode = 'shut'
178+
179+
if _arguments: raise TypeError, 'No optional args expected'
180+
if _no_object != None: raise TypeError, 'No direct arg expected'
181+
182+
183+
_reply, _arguments, _attributes = self.send(_code, _subcode,
184+
_arguments, _attributes)
185+
if _arguments.has_key('errn'):
186+
raise MacOS.Error, aetools.decodeerror(_arguments)
187+
# XXXX Optionally decode result
188+
if _arguments.has_key('----'):
189+
return _arguments['----']
190+
191+
_argmap_open = {
192+
'items' : 'fsel',
193+
}
194+
195+
def open(self, _object, _attributes={}, **_arguments):
196+
"""open: Open folders, files, or applications from a given folder
197+
Required argument: Alias for folder containing the items
198+
Keyword argument items: List of aliases for items in the folder
199+
Keyword argument _attributes: AppleEvent attribute dictionary
200+
"""
201+
_code = 'FNDR'
202+
_subcode = 'sope'
203+
204+
aetools.keysubst(_arguments, self._argmap_open)
205+
_arguments['----'] = _object
206+
207+
208+
_reply, _arguments, _attributes = self.send(_code, _subcode,
209+
_arguments, _attributes)
210+
if _arguments.has_key('errn'):
211+
raise MacOS.Error, aetools.decodeerror(_arguments)
212+
# XXXX Optionally decode result
213+
if _arguments.has_key('----'):
214+
return _arguments['----']
215+
216+
_argmap__print = {
217+
'items' : 'fsel',
218+
}
219+
220+
def _print(self, _object, _attributes={}, **_arguments):
221+
"""print: Print items from a given folder
222+
Required argument: Alias for folder containing the items
223+
Keyword argument items: List of aliases for items in folder
224+
Keyword argument _attributes: AppleEvent attribute dictionary
225+
"""
226+
_code = 'FNDR'
227+
_subcode = 'spri'
228+
229+
aetools.keysubst(_arguments, self._argmap__print)
230+
_arguments['----'] = _object
231+
232+
233+
_reply, _arguments, _attributes = self.send(_code, _subcode,
234+
_arguments, _attributes)
235+
if _arguments.has_key('errn'):
236+
raise MacOS.Error, aetools.decodeerror(_arguments)
237+
# XXXX Optionally decode result
238+
if _arguments.has_key('----'):
239+
return _arguments['----']
240+
241+
_argmap_put_away = {
242+
'items' : 'fsel',
243+
}
244+
245+
def put_away(self, _object, _attributes={}, **_arguments):
246+
"""put away: Put away items from a given folder
247+
Required argument: Alias for folder containing the items
248+
Keyword argument items: List of aliases to items in folder
249+
Keyword argument _attributes: AppleEvent attribute dictionary
250+
Returns: undocumented, typecode 'alis'
251+
"""
252+
_code = 'FNDR'
253+
_subcode = 'sput'
254+
255+
aetools.keysubst(_arguments, self._argmap_put_away)
256+
_arguments['----'] = _object
257+
258+
259+
_reply, _arguments, _attributes = self.send(_code, _subcode,
260+
_arguments, _attributes)
261+
if _arguments.has_key('errn'):
262+
raise MacOS.Error, aetools.decodeerror(_arguments)
263+
# XXXX Optionally decode result
264+
if _arguments.has_key('----'):
265+
return _arguments['----']
266+
267+
def restart(self, _no_object=None, _attributes={}, **_arguments):
268+
"""restart: Restart the Macintosh
269+
Keyword argument _attributes: AppleEvent attribute dictionary
270+
"""
271+
_code = 'FNDR'
272+
_subcode = 'rest'
273+
274+
if _arguments: raise TypeError, 'No optional args expected'
275+
if _no_object != None: raise TypeError, 'No direct arg expected'
276+
277+
278+
_reply, _arguments, _attributes = self.send(_code, _subcode,
279+
_arguments, _attributes)
280+
if _arguments.has_key('errn'):
281+
raise MacOS.Error, aetools.decodeerror(_arguments)
282+
# XXXX Optionally decode result
283+
if _arguments.has_key('----'):
284+
return _arguments['----']
285+
286+
_argmap_select = {
287+
'items' : 'fsel',
288+
}
289+
290+
def select(self, _object, _attributes={}, **_arguments):
291+
"""select: Select items in a folder
292+
Required argument: Alias for folder containing the items
293+
Keyword argument items: List of aliases for items in folder
294+
Keyword argument _attributes: AppleEvent attribute dictionary
295+
"""
296+
_code = 'FNDR'
297+
_subcode = 'srev'
298+
299+
aetools.keysubst(_arguments, self._argmap_select)
300+
_arguments['----'] = _object
301+
302+
303+
_reply, _arguments, _attributes = self.send(_code, _subcode,
304+
_arguments, _attributes)
305+
if _arguments.has_key('errn'):
306+
raise MacOS.Error, aetools.decodeerror(_arguments)
307+
# XXXX Optionally decode result
308+
if _arguments.has_key('----'):
309+
return _arguments['----']
310+

0 commit comments

Comments
 (0)