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

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Sun Jan 10 16:33:50 UTC 2010


Author: rousseau
Date: Sun Jan 10 16:33:48 2010
New Revision: 4653

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4653
Log:
pep8 (mostly) clean

Modified:
    website/matrix.py

Modified: website/matrix.py
URL: http://svn.debian.org/wsvn/pcsclite/website/matrix.py?rev=4653&op=diff
==============================================================================
--- website/matrix.py (original)
+++ website/matrix.py Sun Jan 10 16:33:48 2010
@@ -34,19 +34,21 @@
     "<": "&lt;",
     }
 
+
 def html_escape(text):
     """Produce entities within text."""
-    L=[]
+    L = []
     for c in text:
-        L.append(html_escape_table.get(c,c))
+        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
     """
     reader_dict = {}
-    reader_file = open(path+reader)
+    reader_file = open(path + reader)
     for line in reader_file.readlines():
         line = line[0:-1]
         l = line.strip(" ").split(':')
@@ -55,6 +57,7 @@
     reader_file.close()
     return reader_dict
 
+
 def parse_all(path, reader_list):
     """
     parse each reader from list
@@ -66,6 +69,7 @@
         readers[reader] = p
 
     return readers
+
 
 def parse_ini(path, section):
     """
@@ -84,7 +88,7 @@
         for o in config.options(r):
             if o == 'features':
                 # for the features we use a list
-                readers[r][o] = [ config.get(r, o) ]
+                readers[r][o] = [config.get(r, o)]
             else:
                 readers[r][o] = config.get(r, o)
 
@@ -101,6 +105,7 @@
     #pp.pprint(readers["GemPCPinpad.txt"])
     return readers
 
+
 def check_list(path, reader_list):
     """
     Check that all .txt files are listed
@@ -128,6 +133,7 @@
         print "\n".join(real_list)
         print ""
 
+
 def check_supported(path, all_readers):
     """
     Check that all .txt files are mentionned in supported_readers.txt
@@ -148,6 +154,7 @@
         print ""
     #pp.pprint(supported_readers)
 
+
 def get_by_manufacturer(readers):
     """
     return a dict of the readers grouped by manufacturer
@@ -157,6 +164,7 @@
     for r in readers.keys():
         d.setdefault(readers[r]['iManufacturer'], []).append(r)
     return d
+
 
 def generate_page(section, title, comment, readers):
     """
@@ -180,30 +188,31 @@
         # for each reader
         for r in sorted(manufacturer_readers[m]):
             note_layer = main_layer.open_layer('reader',
-                manufacturer = m,
-                product = readers[r]['iProduct'],
-                idVendor = readers[r]['idVendor'],
-                idProduct = readers[r]['idProduct'],
-                image = "img/" + readers[r].get('image', "no_image.png"))
-
-            note_layer.write_layer('descriptor', descriptor = "readers/%s" % r)
+                manufacturer=m,
+                product=readers[r]['iProduct'],
+                idVendor=readers[r]['idVendor'],
+                idProduct=readers[r]['idProduct'],
+                image="img/" + readers[r].get('image', "no_image.png"))
+
+            note_layer.write_layer('descriptor', descriptor="readers/%s" % r)
 
             url = readers[r].get('url', "")
             if url:
                 note_layer.write_layer('url',
-                    url = url,
-                    manufacturer = m,
-                    product = readers[r]['iProduct'])
+                    url=url,
+                    manufacturer=m,
+                    product=readers[r]['iProduct'])
 
             features = ", ".join(readers[r].get('features', ""))
             if features:
-                note_layer.write_layer('features', features = features)
+                note_layer.write_layer('features', features=features)
 
             note = readers[r].get('note', "").split('\n')
             for n in note:
-                note_layer.write_layer('note', contents = n)
+                note_layer.write_layer('note', contents=n)
 
     file_writer.close()
+
 
 def generate_table(readers, field, index, fields):
     """
@@ -253,7 +262,7 @@
     file.write('<tr>')
     file.write("<th>#</th>")
     for f in fields:
-        file.write("<th><a href='%s'>%s</a></th>" % (f+".html", f))
+        file.write("<th><a href='%s'>%s</a></th>" % (f + ".html", f))
     file.write('</tr>\n')
 
     num = 0
@@ -284,18 +293,19 @@
     file.write(footer)
     file.close()
 
+
 def generate_tables(readers):
     """
     generate all the web page tables with all the fields values
     """
-    fields = [ 'section', 'iManufacturer', 'iProduct', 'image', 'idVendor',
+    fields = ['section', 'iManufacturer', 'iProduct', 'image', 'idVendor',
             'idProduct', 'bNumEndpoints', 'bInterfaceClass', 'bcdCCID',
             'bMaxSlotIndex', 'bVoltageSupport', 'dwProtocols',
             'dwDefaultClock', 'dwMaximumClock', 'dwDataRate',
             'dwMaxDataRate', 'dwMaxIFSD', 'dwSynchProtocols',
             'dwMechanical', 'dwFeatures', 'dwMaxCCIDMessageLength',
             'bClassGetResponse', 'bClassEnveloppe', 'wLcdLayout',
-            'bPINSupport', 'bMaxCCIDBusySlots', 'features', 'note' ]
+            'bPINSupport', 'bMaxCCIDBusySlots', 'features', 'note']
 
     for f in fields:
         index = list()
@@ -303,11 +313,11 @@
             index.append([readers[r].get(f, ""), r])
         if f == 'section':
             # hack to sort in the order supported, shouldwork, unsupported
-            index = [(s.replace('supported', 'asupported'),r) for s,r in index]
+            index = [(s.replace('supported', 'asupported'), r) for s, r in index]
         if f in ['dwDefaultClock', 'dwMaximumClock', 'dwDataRate',
                 'dwMaxDataRate', 'dwMaxIFSD', 'dwMaxCCIDMessageLength']:
             # convert from text to decimal
-            index = [(float(s.split(' ')[0])*1000,r) for s,r in index]
+            index = [(float(s.split(' ')[0]) * 1000, r) for s, r in index]
         index.sort()
         sorted_fields = list(fields)
         sorted_fields.remove(f)




More information about the Pcsclite-cvs-commit mailing list