I am trying to generate a python internal structure (a dictionary of dictionaries) with a copy of all todo data from iCal. I got it to work using the following code:
#!/usr/bin/env /usr/bin/pythonw
from appscript import *
from sys import stdout
appCal = app( 'iCal' )
todos = appCal.calendars.filter(its.title != '').todos
# Iterate flattened list, builing a local dictionary of dictionaries, by uid
local_tasks = {}
for task in [ todo for cal in todos() for todo in cal ]:
uid = task.uid.get()
local_tasks[uid] = {
"completion_date" : task.completion_date.get(),
"due_date" : task.due_date.get(),
"priority" : task.priority.get(),
"sequence" : task.sequence.get(),
"stamp_date" : task.stamp_date.get(),
"summary" : task.summary.get(),
"description" : task.description.get(),
"uid" : task.uid.get(),
"url" : task.url.get(),
}
stdout.write('.')
stdout.flush()
stdout.write('\n')
print repr( local_tasks )
stdout.write( "%d tasks\n" % len( local_tasks ) )
The problem is that this appears to execute painstakingly slowly. With 60 todo items in my iCal, the script takes just over 10 seconds to run. My machine i a 2GHz Intel Core Duo iMac.