1# Just enough LaunchServices to get what we want. 2def _load(g=globals()): 3 import objc 4 from Foundation import NSBundle 5 OSErr = objc._C_SHT 6 def S(*args): 7 return ''.join(args) 8 9 FUNCTIONS = [ 10 (u'LSGetApplicationForInfo', 'sII@Io^{FSRef=[80C]}o^@'), 11 ] 12 13 bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework')) 14 objc.loadBundleFunctions(bndl, g, FUNCTIONS) 15globals().pop('_load')() 16 17kLSUnknownType = 0 18kLSUnknownCreator = 0 19kLSRolesViewer = 2 20 21if __name__ == '__main__': 22 err, outRef, outURL = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, u'txt', kLSRolesViewer) 23 print err, outRef.as_pathname(), outURL 24