[Pythonmac-SIG] Announce: OSATools

Michael J. Barber mjb@uma.pt
Wed, 4 Dec 2002 10:37:05 +0000


On Wednesday, December 4, 2002, at 09:37  AM, Paul Berkowitz wrote:

>> Divorced from a real problem, it's a bit difficult to find a good
>> example that is interesting, succinct, and (perhaps most importantly)
>> uses an application that everyone has. Any suggestions?
>
> --------------
>
> tell application "Address Book"
>     set joeBlow to make new person with properties {first name:"Joe", 
> last
> name:"Blow"}
>     tell joeBlow to make new email at end of emails with properties
> {label:"home", value:"jblow@earthlink.com"}
>     save addressbook
> end tell
>
>
> ----------------
>
> Convert that into Python/OSA.
>
That's a great example! Only problem is we exclude those who are using 
10.1; at the moment, I'm still in that group for various reasons. The 
script is a snap to write (thanks to Paul!), maybe someone could test it 
out for me?

"""Example of using OSATools to interface with Address Book.

Requires Mac OS X 10.2+. Example suggested by Paul Berkowitz"""

from OSATools import AppModels

addbook = AppModels.AppleScriptApp("Address Book")
addbook.tellBlock(
	['set joeBlow to make new  person with properties {first 
name:"Joe", last name:"Blow"}',
	 'tell joeBlow to make new email at end of emails with properties 
{label:"home", value:"jblow@earthlink.com"}',
	 'save addressbook'])