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

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Wed Feb 16 14:07:05 UTC 2011


Author: rousseau
Date: Wed Feb 16 14:06:56 2011
New Revision: 5603

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5603
Log:
Add a add_line() function to later factorize code

Modified:
    website/matrix.py

Modified: website/matrix.py
URL: http://svn.debian.org/wsvn/pcsclite/website/matrix.py?rev=5603&op=diff
==============================================================================
--- website/matrix.py (original)
+++ website/matrix.py Wed Feb 16 14:06:56 2011
@@ -361,6 +361,29 @@
     file_writer.close()
 
 
+def add_line(file_desc, num, reader, fields):
+    # define color of the line
+    if num % 2:
+        # even line number
+        color = reader['section']
+    else:
+        # odd line number
+        color = reader['section'] + '_odd'
+    file_desc.write('<tr class="%s">' % color)
+
+    file_desc.write("<td>%d</td>" % num)
+    for f in fields:
+        if f == 'iProduct':
+            file_desc.write("<td><a href='%s.html#%s%s'>%s</a></td>" % (reader['section'], reader['idVendor'], reader['idProduct'], reader[f]))
+        elif f == 'image':
+            file_desc.write('<td><img src="%s" height="100" alt="image"></td>' % ("img/" + reader.get('image', "no_image.png")))
+        elif f == 'features':
+            file_desc.write("<td>%s</td>" % ", ".join(reader[f]))
+        else:
+            file_desc.write("<td>%s</td>" % reader.get(f, ""))
+    file_desc.write('</tr>\n')
+
+
 def generate_table(readers, field, index, fields):
     """
     generate a web page with all the reader attributes
@@ -443,26 +466,7 @@
     num = 0
     for r in index:
         num += 1
-        # define color of the line
-        if num % 2:
-            # even line number
-            color = readers[r]['section']
-        else:
-            # odd line number
-            color = readers[r]['section'] + '_odd'
-        file.write('<tr class="%s">' % color)
-
-        file.write("<td>%d</td>" % num)
-        for f in fields:
-            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 == 'image':
-                file.write('<td><img src="%s" height="100" alt="image"></td>' % ("img/" + readers[r].get('image', "no_image.png")))
-            elif f == 'features':
-                file.write("<td>%s</td>" % ", ".join(readers[r][f]))
-            else:
-                file.write("<td>%s</td>" % readers[r].get(f, ""))
-        file.write('</tr>\n')
+        add_line(file, num, readers[r], fields)
 
     file.write('</table>\n')
 




More information about the Pcsclite-cvs-commit mailing list