[Pcsclite-cvs-commit] r6188 - /website/generate_supported_readers.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Mon Jan 23 10:30:20 UTC 2012


Author: rousseau
Date: Mon Jan 23 10:30:20 2012
New Revision: 6188

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6188
Log:
add a comment if the generated name is different from the one found in
ccid/readers/supported_readers.txt

This feature should not be used anymore if the
ccid/readers/supported_readers.txt is generated from the USB descriptors

Modified:
    website/generate_supported_readers.py

Modified: website/generate_supported_readers.py
URL: http://svn.debian.org/wsvn/pcsclite/website/generate_supported_readers.py?rev=6188&op=diff
==============================================================================
--- website/generate_supported_readers.py (original)
+++ website/generate_supported_readers.py Mon Jan 23 10:30:20 2012
@@ -26,19 +26,26 @@
 from matrix import parse_ini, get_by_manufacturer
 from datetime import date
 
+# add a comment if the generated name is different from the one found in
+# ccid/readers/supported_readers.txt
+Difference = True
+
 
 def generate_header(output_file):
     """
     Generate the file header
     """
-    output_file.write("# list of readers supported by the CCID driver\n")
-    output_file.write("# generated: " + date.today().isoformat() + "\n")
+    output_file.write("#\n")
+    output_file.write("# List of readers supported by the CCID driver\n")
+    output_file.write("# Generated: " + date.today().isoformat() + "\n")
+    output_file.write("#\n")
+    output_file.write("# DO NOT EDIT BY HAND\n")
     output_file.write("\n")
     output_file.write("# Website: http://pcsclite.alioth.debian.org/ccid.html\n")
     output_file.write("\n")
 
 
-def generate_section(output_file, section, readers):
+def generate_section(output_file, section, readers, manual_names):
     """
     Generate a section sorted by VID, PID
     """
@@ -64,13 +71,45 @@
 
         # for each reader
         for reader in sorted(manufacturer_readers[manufacturer]):
-            output_file.write("%s%s:%s:%s %s\n" % (state, 
-                readers[reader]['idVendor'],
-                readers[reader]['idProduct'],
-                readers[reader]['iManufacturer'],
-                readers[reader]['iProduct']))
+            key = "%s:%s" % (readers[reader]['idVendor'],
+                readers[reader]['idProduct'])
+            name = "%s %s" % (readers[reader]['iManufacturer'],
+                readers[reader]['iProduct'])
+            output_file.write("%s%s:%s\n" % (state, key, name))
+            manual_name = manual_names[key]
+            if Difference and manual_name.upper() not in name.upper():
+                output_file.write("# DIFFERENCE: %s (for %s)\n\n" %
+                    (manual_names[key], reader))
 
     output_file.write("\n")
+
+
+def parse_supported_readers(supported_readers):
+    manual_names = dict()
+    names = file(supported_readers).readlines()
+    for line in names:
+        # skip comments
+        if line.startswith("#"):
+            # but get commented readers
+            if line.startswith("#0"):
+                # remove the leading #
+                line = line[1:]
+            else:
+                continue
+
+        # remove newline
+        line = line.rstrip()
+
+        # skip empty lines
+        if line is "":
+            continue
+
+        (vendor, product, name) = line.split(":")
+        key = "%s:%s" % (vendor, product)
+        manual_names[key] = name
+
+    return manual_names
+
 
 def main():
     """
@@ -84,11 +123,17 @@
     unsupported_readers = parse_ini(path, "unsupported")
     disabled_readers = parse_ini(path, "disabled")
 
+    manual_names = parse_supported_readers("ccid/readers/supported_readers.txt")
+
     generate_header(output_file)
-    generate_section(output_file, "supported", supported_readers)
-    generate_section(output_file, "shouldwork", shouldwork_readers)
-    generate_section(output_file, "unsupported", unsupported_readers)
-    generate_section(output_file, "disabled", disabled_readers)
+    generate_section(output_file, "supported", supported_readers,
+        manual_names)
+    generate_section(output_file, "shouldwork", shouldwork_readers,
+        manual_names)
+    generate_section(output_file, "unsupported", unsupported_readers,
+        manual_names)
+    generate_section(output_file, "disabled", disabled_readers,
+        manual_names)
     output_file.close()
 
 if __name__ == "__main__":




More information about the Pcsclite-cvs-commit mailing list