[Pythonmac-SIG] O'Reilly article, iPhoto scripting, Python?

Bob Ippolito bob at redivi.com
Tue Mar 2 12:22:13 EST 2004


It's perfectly possible to set things up such that the code you propose 
is possible.  However, your proposed code would send at least 4*N apple 
events to iPhoto from Python, where has's example sends 1 (and it's 
working code, if you have appscript installed).

-bob

On Mar 2, 2004, at 11:58 AM, Laurent Pierron wrote:

> Oh Yes, very exciting, so the AppleScript is :
>
> tell application "iPhoto"
> 	remove (photos of photo library album where height < 200 or width < 
> 200)
> end tell
>
> In Python, I'll like to write that :
>
> import iPhoto
> map(iPhoto.remove, [photo for photo in 
> iPhoto.photo_library_album.photos if photo.width < 200 or photo.height 
> < 200])
>
> Why isn't it possible ?
>
> Le 1 mars 04, à 21:17, has a écrit :
>
>> Dinu Gherman wrote:
>>
>>> I just found this article about scripting iPhoto on the net which
>>> gives examples in AppleScript and some other P-language, so I wonder
>>> if this kind of stuff can be done nowadays in Python, too?
>>
>> Yes. Appscript isn't quite finished yet, but it's getting close. 
>> Here's the equivalent deletion script [1]:
>>
>>     from appscript import *
>>
>>     app('iPhoto.app').photo_library_album.photos.test(
>>             (its.width < 200) .OR (its.height < 200)
>>             ).remove()
>>
>>
>> There's some sample scripts on my site and bundled with appscript 
>> itself, and I'll release more as I write them.
>>
>> HTH
>>
>> has
>>
>> [1] Brian's original Perl script makes the classic faux-pas of 
>> laboriously iterating where a filter reference would do. See past 
>> posts from me regarding application object references, pointing out 
>> that they're actually queries and not conventional OO object 
>> references as many folks assume.
>> -- 
>> http://freespace.virgin.net/hamish.sanderson/
>>
>> _______________________________________________
>> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>> http://mail.python.org/mailman/listinfo/pythonmac-sig
>>
> --
> Laurent PIERRON
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig




More information about the Pythonmac-SIG mailing list