Fix an amazing number of typos & malformed sentences reported by Detlef
[python/dscho.git] / Mac / Lib / test / testfinderopen.py
blob8ecf424f0be7687e0a1ebe7b75803a30a3c79aad
1 """Make the finder open an application, file or folder"""
3 import Finder_7_0_Suite
4 import aetools
5 import MacOS
6 import sys
7 import macfs
9 SIGNATURE='MACS'
11 class Finder(aetools.TalkTo, Finder_7_0_Suite.Finder_7_0_Suite):
12 pass
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])
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
31 if __name__ == '__main__':
32 main()