From af8accd7a6542788787be75833cf2700d9138255 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Wed, 13 Jan 1999 23:54:46 +0000 Subject: New proposed change to standard library module. Get rid of getallrecipients() and just make getaddrlist() do the right thing (scan all matching headers, not just the first one). Patch submitted to Guido. --- Mailman/pythonlib/rfc822.py | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'Mailman/pythonlib') diff --git a/Mailman/pythonlib/rfc822.py b/Mailman/pythonlib/rfc822.py index 7ce3ff254..e7e4c75ac 100644 --- a/Mailman/pythonlib/rfc822.py +++ b/Mailman/pythonlib/rfc822.py @@ -298,34 +298,21 @@ class Message: def getaddrlist(self, name): """Get a list of addresses from a header. - - Retrieves a list of addresses from a header, where each - address is a tuple as returned by getaddr(). - """ - # New, by Ben Escoto - try: - data = self[name] - except KeyError: - return [] - a = AddrlistClass(data) - return a.getaddrlist() - - def getallrecipients(self): - """Returns a list of the all the recipient addresses. - This list is of 2-tuple elements as returned by getaddr(), but is a - collation of all the To: and Cc: headers found in the message. + Retrieves a list of addresses from a header, where each address is a + tuple as returned by getaddr(). Scans all named headers, so it works + properly with multiple To: or Cc: headers for example. + """ - rawrecips = [] - for h in (self.getallmatchingheaders('to') + - self.getallmatchingheaders('cc')): + raw = [] + for h in self.getallmatchingheaders(name): i = string.find(h, ':') if i > 0: - rawrecips.append(string.strip(h[i+1:])) - alladdrs = string.join(rawrecips, ', ') - a = AddressList(alladdrs) - return a.addresslist - + raw.append(string.strip(h[i+1:])) + alladdrs = string.join(raw, ', ') + a = AddrlistClass(alladdrs) + return a.getaddrlist() + def getdate(self, name): """Retrieve a date field from a header. -- cgit v1.3.1