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

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu May 7 08:08:31 UTC 2009


Author: rousseau
Date: Thu May  7 08:08:31 2009
New Revision: 3489

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3489
Log:
add an image column and correct HTML warnings

Modified:
    website/matrix.py

Modified: website/matrix.py
URL: http://svn.debian.org/wsvn/pcsclite/website/matrix.py?rev=3489&op=diff
==============================================================================
--- website/matrix.py (original)
+++ website/matrix.py Thu May  7 08:08:31 2009
@@ -26,6 +26,21 @@
 
 pp = pprint.PrettyPrinter(indent=4)
 
+html_escape_table = {
+    "&": "&",
+    '"': """,
+    "'": "'",
+    ">": ">",
+    "<": "&lt;",
+    }
+
+def html_escape(text):
+    """Produce entities within text."""
+    L=[]
+    for c in text:
+        L.append(html_escape_table.get(c,c))
+    return "".join(L)
+
 def parse_reader(path, reader):
     """
     parse a reader CCID descriptor and return a dictionnary
@@ -54,7 +69,7 @@
 
 def parse_ini(path, section):
     """
-    parse a foobas.ini file to extract all informations
+    parse a foobar.ini file to extract all informations
     """
     config = ConfigParser.ConfigParser()
     # do not use the default case insensitive transform for key value
@@ -65,6 +80,7 @@
     readers = parse_all(path, reader_list)
     for r in readers.keys():
         readers[r]['section'] = section
+        readers[r]['iManufacturer'] = html_escape(readers[r]['iManufacturer'])
         for o in config.options(r):
             if o == 'features':
                 # for the features we use a list
@@ -202,15 +218,16 @@
   <body>"""
     footer = """
     <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2404298-2"; urchinTracker(); </script>
+    <p>Ludovic Rousseau</p>
   </body>
 </html>"""
     documentation = """
     <p>Click on the column header to sort by that column.</p>
-    <p>The background color indicates the section of the reader:
-    <table border="1">
+    <p>The background color indicates the section of the reader:</p>
+    <table border="1" summary="color codes">
     <tr><td>supported</td>
-    <td bgcolor="#aff">should work</td>
-    <td bgcolor="#faa">unsupported</td></tr></table></p>
+    <td bgcolor="#a0ffff">should work</td>
+    <td bgcolor="#ffa0a0">unsupported</td></tr></table>
     """
 
     file = open(field + ".html", "w")
@@ -232,9 +249,9 @@
     for r in index:
         num += 1
         if readers[r]['section'] == "unsupported":
-            file.write('<tr bgcolor="#faa">')
+            file.write('<tr bgcolor="#ffa0a0">')
         elif readers[r]['section'] == "shouldwork":
-            file.write('<tr bgcolor="#aff">')
+            file.write('<tr bgcolor="#a0ffff">')
         else:
             file.write('<tr>')
         file.write("<td>%d</td>" % num)
@@ -242,7 +259,9 @@
             if f == 'iProduct':
                 file.write("<td><a href='%s.html#%s%s'>%s</a></td>" % (readers[r]['section'], readers[r]['idVendor'], readers[r]['idProduct'], readers[r][f]))
             elif f == 'iManufacturer':
-                file.write('<td><a onmouseover="">%s<img src="%s"></td>' % (readers[r][f], "img/" + readers[r].get('image', "no_image.png")))
+                file.write('<td><a onmouseover="">%s<img src="%s" alt="image"></a></td>' % (readers[r][f], "img/" + readers[r].get('image', "no_image.png")))
+            elif f == 'image':
+                file.write('<td><img src="%s" height="100" alt="image"></td>' % ("img/" + readers[r].get('image', "no_image.png")))
             else:
                 file.write("<td>%s</td>" % readers[r].get(f, ""))
         file.write('</tr>\n')
@@ -258,7 +277,7 @@
     """
     generate all the web page tables with all the fields values
     """
-    fields = [ 'section', 'iManufacturer', 'iProduct', 'idVendor',
+    fields = [ 'section', 'iManufacturer', 'iProduct', 'image', 'idVendor',
             'idProduct', 'bNumEndpoints', 'bInterfaceClass', 'bcdCCID',
             'bMaxSlotIndex', 'bVoltageSupport', 'dwProtocols',
             'dwDefaultClock', 'dwMaximumClock', 'dwDataRate',




More information about the Pcsclite-cvs-commit mailing list