Permalink
Browse files

Added support for multiple e-mail addresses per contact

  • Loading branch information...
redondos committed Feb 15, 2007
1 parent a2389fa commit 0140e45f68e5dd8abbd22bc6b364511e88cc27f3
Showing with 20 additions and 12 deletions.
  1. +0 −1 README
  2. +16 −7 gmailcontacts.py
  3. +4 −4 libgmail-getContactListByName_insensitive.patch
View
1 README
@@ -36,4 +36,3 @@ macro index ,q '<enter-command> set query_command="~/bin/gmailcontacts.py -u red
Bugs:
Queries take too much time, maybe the results should be cached.
-Single-worded contacts make regexp explode.
View
@@ -56,15 +56,24 @@ def main():
if VERBOSE:
print "Looking up: " + lookup
try:
- contact = account.getContacts().getContactListByName(lookup)
- contact_pattern = re.compile('([^ ]*) ([^@ ]*) ([^ ]*)')
- if contact != False:
+ contacts = account.getContacts().getContactListByName(lookup)
+ contacts_pattern = re.compile('[^ ]* ([^@]*) .*')
+ contact_match_pattern = re.compile('[^ ,]*@[^ ,]*.[^ ,]*')
+ if contacts != False:
if VERBOSE:
print "Results:"
- for i in range(len(contact)):
- contact_match = contact_pattern.match(str(contact[i]))
- if contact_match.group(3) != "":
- print contact_match.group(3) + "\t" + contact_match.group(2)
+ for i in range(len(contacts)):
+ contact_name = contacts_pattern.match(str(contacts[i]))
+ contact_item = str(contacts[i]).split()
+ # Name empty? No way, Gmail doesn't let us.
+ # if contact_item[1] != "":
+ c=0
+ for j in range(len(contact_item)):
+ # print contact_item[j]
+ contact_match = contact_match_pattern.match(contact_item[j])
+ if contact_match != None:
+ print contact_match.group() + "\t" + contact_name.group(1)
+ c = c+1
else:
print "No contacts were found."
except:
@@ -1,11 +1,11 @@
---- libgmail.py 2007-02-10 18:45:48.000000000 -0300
-+++ /usr/lib/python2.4/site-packages/libgmail.py 2007-02-10 14:55:01.000000000 -0300
+--- /usr/lib/python2.4/site-packages/libgmail.py 2007-02-10 14:55:01.000000000 -0300
++++ libgmail.py 2007-02-10 18:45:48.000000000 -0300
@@ -1111,7 +1111,7 @@
"""
nameList = []
for entry in self.contactList:
-- if entry.getName().lower().find(name.lower()) != -1:
-+ if entry.getName() == name:
+- if entry.getName() == name:
++ if entry.getName().lower().find(name.lower()) != -1:
nameList.append(entry)
return nameList
def getContactListByEmail(self, email):

0 comments on commit 0140e45

Please sign in to comment.