Skip to content

Instantly share code, notes, and snippets.

@JNRowe
Created March 23, 2010 05:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JNRowe/340873 to your computer and use it in GitHub Desktop.
Save JNRowe/340873 to your computer and use it in GitHub Desktop.
#! /usr/bin/python -tt
"""Generate a sup contacts list from abook"""
import configobj
import os
import sys
def parse(file=None):
if not file:
file = os.path.expanduser("~/.abook/addressbook")
conf = configobj.ConfigObj(file, list_values=False)
for chunk in filter(lambda d: "nick" in d and "email" in d, conf.values()):
print "%(nick)s: %(name)s" % chunk, \
"<%s>" % chunk["email"].split(",")[0]
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] in ("-h", "--help"):
print "%s [addressbook]" % sys.argv[0]
sys.exit(255)
addressbook = sys.argv[1]
else:
addressbook = None
parse(addressbook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment