[Pcsclite-cvs-commit] r3420 - /website/matrix.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu Apr 9 14:01:12 UTC 2009


Author: rousseau
Date: Thu Apr  9 14:01:10 2009
New Revision: 3420

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3420
Log:
add comments and simplify code

Modified:
    website/matrix.py

Modified: website/matrix.py
URL: http://svn.debian.org/wsvn/pcsclite/website/matrix.py?rev=3420&op=diff
==============================================================================
--- website/matrix.py (original)
+++ website/matrix.py Thu Apr  9 14:01:10 2009
@@ -26,12 +26,6 @@
 
 pp = pprint.PrettyPrinter(indent=4)
 
-def merge(*input):
-    """
-    merge all the lists passed as argument
-    """
-    return reduce(list.__add__, input, list())
-
 def parse_reader(path, reader):
     """
     parse a reader CCID descriptor and return a dictionnary
@@ -90,6 +84,9 @@
     return readers
 
 def check_list(path, reader_list):
+    """
+    Check that all .txt files are listed
+    """
     cwd = os.getcwd()
     os.chdir(path)
     real_list = glob.glob("*.txt")
@@ -112,15 +109,23 @@
         raise Exception("readers %s are not listed" % real_list)
 
 def get_by_manufacturer(readers):
+    """
+    return a dict of the readers grouped by manufacturer
+    d['manufacturer'] is a list of the manufacturer's readers
+    """
     d = {}
     for r in readers.keys():
         d.setdefault(readers[r]['iManufacturer'], []).append(r)
     return d
 
 def generate_page(section, title, comment, readers):
+    """
+    generate a web page for the corresponding section
+    """
     # sort the readers by manufacturers
     manufacturer_readers = get_by_manufacturer(readers)
     manufacturers = list(manufacturer_readers)
+    # sort the manufacturers list alphabetically
     manufacturers.sort(key=str.lower)
 
     template = templayer.HTMLTemplate("webpage.template")
@@ -161,6 +166,10 @@
     file_writer.close()
 
 def generate_table(readers, index, fields):
+    """
+    generate a web page with all the reader attributes
+    readers are in the order given by index
+    """
     header = """<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html>
@@ -184,7 +193,7 @@
         file.write("<th>%s</th>" % f)
     file.write('</tr>\n')
 
-    for r in readers:
+    for r in index:
         if readers[r]['section'] == "unsupported":
             file.write('<tr bgcolor="#faa">')
         elif readers[r]['section'] == "shouldwork":
@@ -218,16 +227,16 @@
     supported_readers = parse_ini(path, "supported")
     shouldwork_readers = parse_ini(path, "shouldwork")
     unsupported_readers = parse_ini(path, "unsupported")
-    reader_list = merge(supported_readers.keys(),
-            shouldwork_readers.keys(), unsupported_readers.keys())
-    #pp.pprint(reader_list)
-    check_list(path, reader_list)
+
+    # all_readers contain the union of the 3 lists
+    all_readers = dict(supported_readers)
+    all_readers.update(shouldwork_readers)
+    all_readers.update(unsupported_readers)
+
+    check_list(path, all_readers.keys())
 
     generate_page("supported", "Supported CCID readers/ICCD tokens", "If you are a reader manufacturer and your reader is not listed here then contact me at ludovic.rousseau at free.fr", supported_readers)
     generate_page("shouldwork", "Should work but untested by me", "The CCID readers and ICCD tokens listed bellow should work with the driver but have not be validated by me. I would like to get these readers to perform test and validation and move them in the supported list above. If you are one of the manufacturers, please, contact me at ludovic.rousseau at free.fr.", shouldwork_readers)
     generate_page("unsupported", "Unsupported or partly supported CCID readers", "These readers have problems or serious limitations.", unsupported_readers)
 
-    all_readers = dict(supported_readers)
-    all_readers.update(shouldwork_readers)
-    all_readers.update(unsupported_readers)
     generate_tables(all_readers)




More information about the Pcsclite-cvs-commit mailing list