[Pythonmac-SIG] appscript introspection?

Ned Deily nad at acm.org
Sat Feb 11 06:35:46 CET 2006


In article <17389.27662.815348.297434 at montanaro.dyndns.org>,
 skip at pobox.com wrote:
> I'm trying to drive iCal using appscript.  I can follow simple examples,
> mostly like a parrot though.  This works, for example:
> 
>     ev = app('iCal').calendars.filter(its.title=="Home").events
>     events = zip(ev.start_date.get(), ev.end_date.get(), 
>                  ev.summary.get(), ev.description.get())
> 
> but I haven't found anywhere that lists all the attributes of an event, so I
> can't tell what it has other than start_date, end_date, summary and
> description.  If I don't have an example to use as a cheat sheet, how can I
> tell how to add an alarm to an event?  Where can I find such information?

1. appscript supplies a help method for appscript objects.  See:
<http://freespace.virgin.net/hamish.sanderson/appscripthelpsystem.html>

In your example:

>>> ev.help()
=========================================================================
=======
Appscript Help (-t)

Reference: app(u'/Applications/iCal.app').calendars.filter(its.title == 
'Home').events 

-------------------------------------------------------------------------
------- 
Description of reference

Element: events --  

Terminology for event class

Class: event -- This class represents an event. 
    Parent: 
        (Bad terminology: can't find class with AE code '****'.) 
    Properties: 
        description : Unicode -- The events notes. 
        start_date : DateTime -- The event start date. 
        end_date : DateTime -- The event end date. 
        allday_event : Boolean -- True if the event is an all-day event 
        recurrence : Unicode -- The iCalendar (RFC 2445) string 
describing the event recurrence, if defined 
        sequence : Integer (r/o) -- The event version. 
        stamp_date : DateTime (r/o) -- The event modification date. 
        excluded_dates : list of DateTime -- The exception dates. 
        status : k.cancelled | k.confirmed | k.none | k.tentative -- The 
event status. 
        summary : Unicode -- This is the event summary. 
        location : Unicode -- This is the event location. 
        uid : Unicode (r/o) -- A unique event key. 
        url : Unicode -- The URL associated to the event. 
    Elements: 
        attendees --  
        display_alarms --  
        mail_alarms --  
        open_file_alarms --  
        sound_alarms --  

=========================================================================
======= 
app(u'/Applications/iCal.app').calendars.filter(its.title == 
'Home').events
>>> 

2. It may be more convenient to use Script Editor.app to browse the 
application's terminology resources.

But, as has has noted here before, you can't always trust what any 
application says is available.  There's often a lot of trial and error 
to discover what works and what doesn't.

See, for example:
<http://article.gmane.org/gmane.comp.python.apple/6726>
-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list