Created
February 4, 2009 05:14
-
-
Save davglass/57951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import vobject | |
from cStringIO import StringIO | |
import os, sys, string | |
''' | |
Simple script to parse an Apple Addressbook export file and | |
turn it into a Mutt aliases file | |
-- | |
Install vobject: | |
easy_install vobject | |
''' | |
f = open('./vCards.vcf') | |
fileStr = StringIO(f.read()).getvalue() | |
v = vobject.readComponents(fileStr) | |
store = [] | |
for i in v: | |
try: | |
if i.fn and i.email: | |
if i.fn.value != i.email.value: | |
nick = i.fn.value.replace(' ', '').replace('.', '').lower() | |
if not nick in store: | |
store.append(nick) | |
print "alias %s %s <%s>" % (nick, i.fn.value, i.email.value) | |
except AttributeError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment