comparison roundup/mailgw.py @ 1299:b2d04ce03802

Email improvements. - updated email package address formatting (deprecation) - copied email address quoting from email v2.4.3 so we're consistent with 2.2 - email summary extraction now takes the first whole sentence or line - whichever is longer
author Richard Jones <richard@users.sourceforge.net>
date Tue, 05 Nov 2002 22:59:46 +0000
parents 3a38af77b87c
children 3758a5af985f
comparison
equal deleted inserted replaced
1298:f0ab014eaf72 1299:b2d04ce03802
71 set() method to add the message to the item's spool; in the second case we 71 set() method to add the message to the item's spool; in the second case we
72 are calling the create() method to create a new node). If an auditor raises 72 are calling the create() method to create a new node). If an auditor raises
73 an exception, the original message is bounced back to the sender with the 73 an exception, the original message is bounced back to the sender with the
74 explanatory message given in the exception. 74 explanatory message given in the exception.
75 75
76 $Id: mailgw.py,v 1.98 2002-10-21 22:03:09 richard Exp $ 76 $Id: mailgw.py,v 1.99 2002-11-05 22:59:46 richard Exp $
77 ''' 77 '''
78 78
79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
80 import time, random, sys 80 import time, random, sys
81 import traceback, MimeWriter 81 import traceback, MimeWriter
911 # we keep quoted bits if specified in the config 911 # we keep quoted bits if specified in the config
912 if keep_citations: 912 if keep_citations:
913 l.append(section) 913 l.append(section)
914 continue 914 continue
915 # keep this section - it has reponse stuff in it 915 # keep this section - it has reponse stuff in it
916 if not summary:
917 # and while we're at it, use the first non-quoted bit as
918 # our summary
919 summary = line
920 lines = lines[lines.index(line):] 916 lines = lines[lines.index(line):]
921 section = '\n'.join(lines) 917 section = '\n'.join(lines)
918 # and while we're at it, use the first non-quoted bit as
919 # our summary
920 summary = section
922 921
923 if not summary: 922 if not summary:
924 # if we don't have our summary yet use the first line of this 923 # if we don't have our summary yet use the first line of this
925 # section 924 # section
926 summary = lines[0] 925 summary = section
927 elif signature.match(lines[0]) and 2 <= len(lines) <= 10: 926 elif signature.match(lines[0]) and 2 <= len(lines) <= 10:
928 # lose any signature 927 # lose any signature
929 break 928 break
930 elif original_message.match(lines[0]): 929 elif original_message.match(lines[0]):
931 # ditch the stupid Outlook quoting of the entire original message 930 # ditch the stupid Outlook quoting of the entire original message
932 break 931 break
933 932
934 # and add the section to the output 933 # and add the section to the output
935 l.append(section) 934 l.append(section)
936 935
936 # figure the summary - find the first sentence-ending punctuation or the
937 # first whole line, whichever is longest
938 sentence = re.search(r'^([^!?\.]+[!?\.])', summary)
939 if sentence:
940 sentence = sentence.group(1)
941 else:
942 sentence = ''
943 first = eol.split(summary)[0]
944 summary = max(sentence, first)
945
937 # Now reconstitute the message content minus the bits we don't care 946 # Now reconstitute the message content minus the bits we don't care
938 # about. 947 # about.
939 if not keep_body: 948 if not keep_body:
940 content = '\n\n'.join(l) 949 content = '\n\n'.join(l)
941 950

Roundup Issue Tracker: http://roundup-tracker.org/