[Pythonmac-SIG] Please critique my first appscript - a fix for Palm sync of iCal Tasks (for kGTD)
has
hengist.podd at virgin.net
Wed Aug 30 15:53:42 CEST 2006
Marcin Komorowski wrote:
> Please kindly critique my code - what could I have done better?
> What would have made this code more Pythonic?
Not familiar with Palm syncing or related iCal issues, but a few
minor pointers on the appscript side, FWIW:
(Note: these comments apply to the latest appscript 0.16.2 release,
though I recommend upgrading as soon as is convenient.)
> #!/usr/bin/env /usr/bin/pythonw
'pythonw' is no longer required by appscript; 'python' is fine.
'pythonw' is only needed when using the osax package to display
dialog boxes.
> cal_todos = appCal.calendars.filter(its.name !=
> '').todos.properties()
The filter() method will be going away in appscript 0.17.0. The new
filter syntax is:
cal_todos = appCal.calendars[its.name != ''].todos.properties()
The current release supports both forms to provide users a period of
grace in which to update their existing scripts.
> if task[ k.class__ ] == k.todo:
This test shouldn't be necessary, as the previous query should only
return todos.
Also, not sure where the k.class__ thing was coming from (presumably
a bug in an earlier version) but it's now k.class_, which is correct.
> k_decode = {
> k.priority : "k.priority",
> k.due_date : "k.due_date",
> k.completion_date : "k.completion_date",
> k.description : "k.description",
> k.url : "k.url",
> k.uid : "k.uid",
> k.summary : "k.summary",
> k.class__ : "k.class__"
> }
This table is unnecessary as Keyword objects can provide their own
string representations. Just delete it and change:
> myDebug( " field %s: " % k_decode[field] );
to:
myDebug( " field %s: " % field )
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list