diff --git a/notmuch_addresses.py b/notmuch_addresses.py index 74a743c..866b327 100755 --- a/notmuch_addresses.py +++ b/notmuch_addresses.py @@ -15,7 +15,7 @@ ## GNU General Public License for more details. ## NOTE: This script requires the notmuch python bindings. - + import notmuch import ConfigParser import optparse @@ -43,7 +43,7 @@ class EmailsWithNames(object): as a list email addresses (with or without best-choice real names), sorted by frequency. """ - + def __init__(self): self.emails = {} @@ -92,7 +92,7 @@ class EmailsWithNames(object): return names[1] def sorted_email_list(self): - return sorted(self.emails.keys(), + return sorted(self.emails.keys(), key=self.email_freq, reverse=True) @@ -105,7 +105,7 @@ class NotmuchAddressMatcher(object): """A simple address matcher, based on information information from the user's $HOME/.notmuch-config file. """ - + def __init__(self, query_name, match_function=None): """ """ @@ -167,15 +167,15 @@ class NotmuchAddressMatcher(object): full_name = addr[0] split_names = full_name.split(" ") mail = addr[1] - if (len([name for name in split_names + if (len([name for name in split_names if self.match_function(name)]) > 0 - or + or self.match_function(full_name) - or + or self.match_function(mail)): - + emails.add_email_and_name(mail, addr[0]) - + self.matches = emails.sorted_email_and_names_list() if __name__ == '__main__': @@ -187,4 +187,4 @@ if __name__ == '__main__': matcher = NotmuchAddressMatcher(name) matcher.generate_matches() - for elem in matcher.matches: print (elem) + for elem in matcher.matches: print (elem.encode('utf-8'))