2009-02-23

PyS60 script to summarize top persons in SMS inbox and outbox

This requires the latest version of PyS60 (1.9.x):
# -*- coding:utf-8 -*-
import appuifw, collections, e32, inbox

def summarize_box(box, box_name):
counter = collections.defaultdict(int)
for message_id in box.sms_messages():
counter[box.address(message_id)] += 1

content = "Persons in " + box_name + ":\n"
for (name, count) in sorted(counter.iteritems(), key=lambda (x,y):(y,x), reverse=True):
content += u"%-3d: %s\n" % (count, name)

return content

content = summarize_box(inbox.Inbox(), 'Inbox')
content += "\n"
content += summarize_box(inbox.Inbox(inbox.ESent), 'Sent')

lock = e32.Ao_lock()
appuifw.app.body = appuifw.Text(content)
appuifw.app.exit_key_handler = lock.signal
lock.wait()

No comments: