[Pcsclite-cvs-commit] r5605 - /website/matrix.py
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Wed Feb 16 14:17:53 UTC 2011
Author: rousseau
Date: Wed Feb 16 14:17:48 2011
New Revision: 5605
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5605
Log:
Parse .txt with 2 interfaces like the Gemalto ProxDU
Modified:
website/matrix.py
Modified: website/matrix.py
URL: http://svn.debian.org/wsvn/pcsclite/website/matrix.py?rev=5605&op=diff
==============================================================================
--- website/matrix.py (original)
+++ website/matrix.py Wed Feb 16 14:17:48 2011
@@ -43,22 +43,41 @@
return "".join(L)
-def parse_reader(path, reader):
- """
- parse a reader CCID descriptor and return a dictionnary
+def parse_interface(lines):
+ """
+ parse a reader CCID interface and return a dictionnary
"""
reader_dict = {}
reader_dict['features'] = list()
- reader_file = open(path + reader)
- for line in reader_file.readlines():
+ for line in lines:
+ # remove the \n
line = line[0:-1]
+
l = line.strip(" ").split(':')
if (len(l) > 1):
reader_dict[l[0]] = l[1].strip(" ")
- reader_file.close()
+
return reader_dict
+
+
+def parse_reader(patch, reader):
+ """
+ parse a reader CCID descriptor and return a list of interfaces
+ """
+ lines = open(path + reader).readlines()
+
+ # split the .txt file per interface
+ interfaces = list()
+ interface = list()
+ for line in lines:
+ if line.split(':')[0] == ' idVendor':
+ interface = list()
+ interfaces.append(interface)
+ interface.append(line)
+
+ return interfaces
def parse_all(path, reader_list):
@@ -68,8 +87,18 @@
"""
readers = {}
for reader in reader_list:
- p = parse_reader(path, reader)
- readers[reader] = p
+ # split the .txt file per interface
+ interfaces = parse_reader(path, reader)
+
+ for interface in interfaces:
+ p = parse_interface(interface)
+ if reader in readers:
+ # second interface
+ readers[reader]['features'].append("Multi interface reader")
+ p['features'].append("Second interface")
+ readers[reader]['interface'] = p
+ else:
+ readers[reader] = p
return readers
@@ -103,6 +132,15 @@
readers[r]['features'].append("PIN Modification")
if int(readers[r]['dwFeatures'], 16) & 0x0800:
readers[r]['features'].append("ICCD")
+
+ if 'interface' in readers[r]:
+ second_interface = readers[r]['interface']
+ first_interface = readers[r]
+ second_interface['section'] = section
+ for elt in first_interface['features']:
+ second_interface['features'].append(elt)
+ if 'image' in first_interface:
+ second_interface['image'] = first_interface['image']
#pp.pprint(readers["GemPCPinpad.txt"])
return readers
@@ -468,6 +506,10 @@
num += 1
add_line(file, num, readers[r], fields)
+ if 'interface' in readers[r]:
+ num += 1
+ add_line(file, num, readers[r]['interface'], fields)
+
file.write('</table>\n')
file.write("<hr><p>Generated: %s</p>" % time.asctime())
More information about the Pcsclite-cvs-commit
mailing list