diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-10-05 13:58:14 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-10-05 13:58:14 +0100 |
commit | f34f2a23b355f020759f714eb8fb567871de587c (patch) | |
tree | ac5c2bca815b4cb4c770ed4ccbb2775adf4e9784 /clab | |
parent | 5b042d5679e1d61e432bd7812ac81d45a574dcda (diff) | |
download | clab-f34f2a23b355f020759f714eb8fb567871de587c.tar.gz |
Output each name/addr only once with mutt-query
Diffstat (limited to 'clab')
-rwxr-xr-x | clab | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -147,12 +147,18 @@ class CommandLineAddressBook(cliapp.Application): self.output.write('No matches\n') sys.exit(1) self.output.write('clab found matches:\n') + + name_addr_pairs = set() for entry in entries: name = entry.get_single('name', '') emails = entry.get_subdict('email') for email in emails: - n = name.encode('utf-8') - self.output.write('%s\t%s\n' % (emails[email], n)) + name_addr_pairs.add((name, emails[email])) + + for name, addr in sorted(name_addr_pairs): + n = name.encode('utf-8') + a = addr.encode('utf-8') + self.output.write('%s\t%s\n' % (a, n)) CommandLineAddressBook().run() |