annotate Mac/Lib/test/testfinderopen.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 0f51f1d70d45
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4317
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 """Make the finder open an application, file or folder"""
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 import Finder_7_0_Suite
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 import aetools
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 import MacOS
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 import sys
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 import macfs
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9 SIGNATURE='MACS'
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 class Finder(aetools.TalkTo, Finder_7_0_Suite.Finder_7_0_Suite):
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12 pass
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 def open_in_finder(file):
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 """Open a file thru the finder. Specify file by name or fsspec"""
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 finder = Finder(SIGNATURE)
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 fss = macfs.FSSpec(file)
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 vRefNum, parID, name = fss.as_tuple()
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19 dir_fss = macfs.FSSpec((vRefNum, parID, ''))
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 file_alias = fss.NewAlias()
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21 dir_alias = dir_fss.NewAlias()
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 return finder.open(file_alias, items=[file_alias])
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24 def main():
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 fss, ok = macfs.PromptGetFile('File to launch:')
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 if not ok: sys.exit(0)
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27 result = open_in_finder(fss)
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 if result:
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 print 'Result: ', result
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
31 if __name__ == '__main__':
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 main()
0f51f1d70d45 Created Finder 7.0 AE interface and a test program that uses the
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33