[Pythonmac-SIG] appscript with todos in iCal seams very slow
Marcin Komorowski
marcink at ieee.org
Sun Aug 6 16:57:56 CEST 2006
Hey All,
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.
Any idea how this could be sped up?
Thank You,
Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20060806/1897b558/attachment.html
More information about the Pythonmac-SIG
mailing list