[Nym3-commit] r229 - trunk/nym3
jr at conuropsis.org
jr at conuropsis.org
Wed May 4 12:32:52 CEST 2005
Author: jr
Date: 2005-05-04 12:32:51 +0200 (Wed, 04 May 2005)
New Revision: 229
Modified:
trunk/nym3/Mail.py
Log:
Add the bitfield to list conversion
Modified: trunk/nym3/Mail.py
===================================================================
--- trunk/nym3/Mail.py 2005-05-04 10:14:18 UTC (rev 228)
+++ trunk/nym3/Mail.py 2005-05-04 10:32:51 UTC (rev 229)
@@ -103,6 +103,17 @@
t[q] = t[q] | (1 << r)
return chr(t[0])+chr(t[1])
+def bf2list(bf):
+ """take a 2 octets big endian string and output the associated
+ list of indexes"""
+ assert (len(bf) == 2 and type(bf) == str)
+ l = []
+ for i in range(2):
+ for j in range(8):
+ if ord(bf[i]) & (1 << j):
+ l.append(i * 8 + j)
+ return l
+
def b2s(c):
"""return a string of length 2 representing the byte c in hex"""
i = ord(c)
More information about the Nym3-commit
mailing list