[Nym3-commit] r268 - trunk/nym3/Client
jr at conuropsis.org
jr at conuropsis.org
Sun May 22 02:11:57 CEST 2005
Author: jr
Date: 2005-05-22 02:11:56 +0200 (Sun, 22 May 2005)
New Revision: 268
Modified:
trunk/nym3/Client/Main.py
Log:
add a function that converts a list of references to mids in mids
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-05-21 01:09:38 UTC (rev 267)
+++ trunk/nym3/Client/Main.py 2005-05-22 00:11:56 UTC (rev 268)
@@ -160,6 +160,38 @@
raise Exception("unable to determine XNymSeq")
return index
+def is_hex_mid(s):
+ try:
+ ds = binascii.unhexlify(s)
+ except TypeError:
+ return False
+ return len(ds) <= Mail.midLen
+
+def decode_message_references(refs, keys, h):
+ """Generate a list of mids from a list of message references, refs,
+ a list of keys and a hashtable.
+ a reference is either a mid or a string of the format <key>:<val>,
+ where key is in keys and does not contain the caracter ':'.
+ h is a hashtable of hashtable: h[<key>][<int>] contains the mid
+ corresponding to a given int for one key."""
+ l = []
+ for e in refs:
+ if ':' not in e:
+ if is_hex_mid(e):
+ l.append(e)
+ else:
+ print "%s: not a valid mid" % e
+ else:
+ s = e.split(':', 1)
+ if s[0] not in keys:
+ print "%s: not a valid index key" % s[0]
+ continue
+ try:
+ l.append(h[s[0]][s[1]])
+ except KeyError:
+ print "%s: not a valid index for key %s" % (s[1], s[0])
+ return l
+
def processMessage(msg, config, ui, nickname):
"""process incoming control message"""
More information about the Nym3-commit
mailing list