This one checks to make sure my Gmail Contacts’ names are spelt how the contact spells them.

It looks at emails sent from the contact, and compares the sender name with the name on file for that contact.

import libgmail # http://libgmail.sourceforge.net/

ga = libgmail.GmailAccount("email@gmail.com", "password")
ga.login()
all_contacts = ga.getContacts().getAllContacts()

def test_thread(thread, contact):
    for message in thread:
        if message.sender.lower() != contact.email.lower():
            continue
        if '@' in message.author_fullname:
            continue
        if message.author_fullname == contact.name:
            return True
        else:
            print "\t", message.author_fullname, "->", contact.name
            return True

for contact in all_contacts:
    results = ga.getMessagesByQuery("from: %s -is:chat" % contact.email)
    if not results:
        print "%s -------No Email" % contact.email
        continue
    for thread in results:
        result = test_thread(thread, contact)
        if result:
            break
    else:
        print "%s -------No Good Email" % contact.email
Advertisements