Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 32 lines (24 sloc) 930 Bytes
#! /usr/bin/python -tt
"""Generate an org-mode input file for birthday reminders
This fetches the information from abook_, where I store birthdate information in
the ``custom2`` field.
.. _abook: http://abook.sourceforge.net/
"""
import ConfigParser
import datetime
import os
data = ConfigParser.ConfigParser()
data.read(os.path.expanduser("~/.abook/addressbook"))
birthdays = filter(lambda x: "custom2" in data.options(x),
data.sections())
print "# THIS FILE IS AUTOGENERATED FROM ABOOK DATA"
print "* Birthdays"
for record in birthdays:
try:
name = data.get(record, "nick")
except ConfigParser.NoOptionError:
name = data.get(record, "name")
birthdate = datetime.datetime.strptime(data.get(record, "custom2"),
"%Y-%m-%d")
print "%%%%(diary-anniversary %s) %s is %%d years old" \
% (birthdate.strftime("%Y %m %d"), name)