[Pythonmac-SIG] obtaining versions of application bundles

brad.allen at omsdal.com brad.allen at omsdal.com
Fri Oct 22 06:58:30 CEST 2004


Bob Ippolito <bob at redivi.com> wrote on 10/21/2004 07:08:49 PM:

> With PyObjC:
>
>  >>> from Foundation import *
>  >>> bndl = NSBundle.bundleWithPath_(u'/Applications/iTunes.app')
>  >>> bndl.infoDictionary()[u'CFBundleVersion']
> u'4.6'
>
> Without:
>
>  >>> import plistlib
>  >>>
> plistlib.Plist.fromFile(u'/Applications/iTunes.app/Contents/
> Info.plist')[u'CFBundleVersion']
> '4.6'

Thanks! I'm glad to know there's an easy way to get this done in the short
term without having to install PyObjC, even though long term I will
probably want to have PyObjC deployed as part of our standard Mac
configuration.

> (note that neither of these approaches will work for CFM applications
> that are not an application bundle.. you would need to read the
> resource fork and get the plist resource.. I think it's 'plst',..)

We have already crossed that bridge by hiring a developer (Walker Hale) to
build a Python module to do that. He came up with a way to do it using
Python's built-in support for Carbon on OS X. I'm hoping my employer will
allow me to post more of the project code publicly, because we can benefit
from "open source" scrutiny, and because some of it may prove useful to
others.




More information about the Pythonmac-SIG mailing list