[Pythonmac-SIG] ANN: LaunchServices 0.1 - Pythonic wrapper for the
Launch Services API
Bob Ippolito
bob at redivi.com
Tue Aug 26 10:07:55 EDT 2003
Have you ever tried to figure out how to find an application by its
creator signature? Or the editor/viewer of a particular file type?
The "user interface names" for paths?
Well, I figured it out. Apple's API to do it is called Launch Services
(part of ApplicationServices.framework). It doesn't have a whole lot
of documentation, but reading the header file was sufficient. I
developed a Pyrex wrapper around it, leveraging the (meager and buggy
:)) CoreFoundation support that comes stock with Python 2.3. I'm
basically using this as a way to make the application-finding code for
aeve sane. A new version of aeve should be coming sometime in the next
two weeks or so.
Example usage:
>>> import LaunchServices as LS
>>> LS.GetDisplayNameForPath('/')
u'Crack'
>>> LS.GetKindStringForPath('/')
u'Volume'
>>> LS.GetApplicationPathForInfo(extension='mp3')
u'/Applications/iTunes.app'
>>> LS.GetApplicationPathForInfo(creator='MACS')
u'/System/Library/CoreServices/Finder.app'
>>> LS.FindApplicationPath(bundle='com.apple.iChat')
u'/Applications/iChat.app'
I'm sure somone will find this useful. I made sure everything has doc
strings, and it's fully tested (in normal use, not for memory leaks
yet) against Jack's Python 2.3 (#2, Jul 30 2003, 11:45:28).
homepage:
http://undefined.org/python/
pydoc documentation:
http://undefined.org/python/LaunchServices-0.1-pydoc.html
source tarball:
http://undefined.org/python/LaunchServices-0.1.tar.gz
PackageManager URL (Python 2.3 - 10.2.x):
http://undefined.org/python/pimp/darwin-6.6-Power_Macintosh.plist
-bob
More information about the Pythonmac-SIG
mailing list