From: <lu...@us...> - 2009-11-13 19:54:06
|
Revision: 325 http://pyscard.svn.sourceforge.net/pyscard/?rev=325&view=rev Author: ludov Date: 2009-11-13 19:53:58 +0000 (Fri, 13 Nov 2009) Log Message: ----------- normalize'): allow more than one space character between hex digits Thanks to Alexei Bouznik for the patch Modified Paths: -------------- trunk/contrib/parseATR/parseATR.py Modified: trunk/contrib/parseATR/parseATR.py =================================================================== --- trunk/contrib/parseATR/parseATR.py 2009-11-12 12:34:38 UTC (rev 324) +++ trunk/contrib/parseATR/parseATR.py 2009-11-13 19:53:58 UTC (rev 325) @@ -41,9 +41,17 @@ "3B A7 00 40 18 80 65 A2 08 01 01 52" "3B:A7:00:40:18:80:65:A2:08:01:01:52" """ - atr = atr.replace(":", " ") - atr = atr.split(" ") - atr = map(lambda x: int(x,16), atr) + atr = atr.replace(":", "") + atr = atr.replace(" ", "") + + res = [] + while len(atr) >= 2: + byte, atr = atr[:2], atr[2:] + res.append(byte) + if len(atr) > 0: + raise ParseAtrException('warning: odd string, remainder: %r' % atr) + + atr = map(lambda x: int(x,16), res) return atr def int2bin(i, padding = 8): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |