blob: 8ecf424f0be7687e0a1ebe7b75803a30a3c79aad [file] [log] [blame]
Jack Jansen35bfd3f1996-09-19 10:49:53 +00001"""Make the finder open an application, file or folder"""
2
3import Finder_7_0_Suite
4import aetools
5import MacOS
6import sys
7import macfs
8
9SIGNATURE='MACS'
10
11class Finder(aetools.TalkTo, Finder_7_0_Suite.Finder_7_0_Suite):
12 pass
13
14def 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
24def 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
31if __name__ == '__main__':
32 main()
33