[Nym3-commit] r258 - trunk/nym3

jr at conuropsis.org jr at conuropsis.org
Thu May 12 02:14:13 CEST 2005


Author: jr
Date: 2005-05-12 02:14:11 +0200 (Thu, 12 May 2005)
New Revision: 258

Modified:
   trunk/nym3/Mail.py
Log:
add a function that extracts the sequence number of a synopsis


Modified: trunk/nym3/Mail.py
===================================================================
--- trunk/nym3/Mail.py	2005-05-11 23:40:21 UTC (rev 257)
+++ trunk/nym3/Mail.py	2005-05-12 00:14:11 UTC (rev 258)
@@ -44,6 +44,8 @@
 oldestMid = chr(0) * midLen
 """Special value of a mid, older than any othany other mid"""
 
+class SeqNotFound(Exception): pass 
+
 def synopsize(msg, seq):
     """Synopsizes a message : keeps a set of headers and the beginning of
     the body of the mail
@@ -82,6 +84,17 @@
 	subj_f = ""
     return "From: %s\nSubject: %s" % (from_f, subj_f)
 
+def XNymSeq(synopsis):
+    """returns an integer, the sequence number of the provided synopsis.
+    if it is absent throws a SeqNotFound exception, ValueError if not an
+    integer string """
+    par = email.Parser.HeaderParser()
+    syn = par.parsestr(synopsis)
+    seq = syn['X-Nym-Sequence']
+    if seq == None:
+	raise SeqNotFound()
+    return int(seq)
+
 def tmpFileMsg(body):
     """write body in a temp file name and return a file name of this file
     """



More information about the Nym3-commit mailing list