[Nym3-commit] r33 - trunk
nym3-devel@lists.noreply.org
nym3-devel@lists.noreply.org
Wed, 28 Jul 2004 18:13:46 +0200
Author: laurent
Date: 2004-07-28 18:13:45 +0200 (Wed, 28 Jul 2004)
New Revision: 33
Added:
trunk/Mail.py
Log:
Add synopsize.
Added: trunk/Mail.py
===================================================================
--- trunk/Mail.py 2004-07-28 16:12:13 UTC (rev 32)
+++ trunk/Mail.py 2004-07-28 16:13:45 UTC (rev 33)
@@ -0,0 +1,29 @@
+
+#
+
+import re
+
+slen = 180
+
+def synopsize(msg):
+ vheaders = [ 'Cc', 'From', 'Date', 'In-Reply-To', 'Sender',
+ 'Message-Id', 'References', 'Return-Path', 'Subject',
+ 'To', 'X-Anonymous', 'X-Spam-Level']
+ a = re.search("""\n\n""", msg)
+ if a:
+ headers = msg[0 : a.start(0)]
+ body = msg[a.start(0) + 1: a.start(0) + slen]
+ else:
+ headers = msg
+ body = ''
+ res = ''
+ for i in vheaders:
+ a = re.search('^(' + i + ':.*)$', headers, re.M)
+ if a:
+ res = res + a.group(1)[0:80] + "\n" # TODO : append?
+
+ return res + 'X-Octets: ' + repr(len(msg)) + "\n" + body
+
+if __name__ == '__main__':
+ import sys
+ print synopsize(sys.stdin.read())