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

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu Jan 12 13:48:32 UTC 2012


Author: rousseau
Date: Thu Jan 12 13:48:31 2012
New Revision: 6169

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6169
Log:
generate the supported_readers.txt used by the CCID driver

Added:
    website/generate_supported_readers.py   (with props)

Added: website/generate_supported_readers.py
URL: http://svn.debian.org/wsvn/pcsclite/website/generate_supported_readers.py?rev=6169&op=file
==============================================================================
--- website/generate_supported_readers.py (added)
+++ website/generate_supported_readers.py Thu Jan 12 13:48:31 2012
@@ -1,0 +1,95 @@
+#!/usr/bin/python
+
+"""
+#    generate_supported_readers.py generate the supported_readers.txt
+#    used by the CCID driver
+#    Copyright (C) 2012  Ludovic Rousseau
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+"""
+
+# $Id$
+
+import ConfigParser
+from matrix import parse_ini, get_by_manufacturer
+from datetime import date
+
+
+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("# Website: http://pcsclite.alioth.debian.org/ccid.html\n")
+    output_file.write("\n")
+
+
+def generate_section(output_file, section, readers):
+    """
+    Generate a section sorted by VID, PID
+    """
+    output_file.write("##########################\n")
+    output_file.write("# section: " + section + "\n")
+    output_file.write("##########################\n")
+
+    # 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)
+
+    if section == "disabled":
+        state = "#"
+    else:
+        state = ""
+
+    # for each manufacturer
+    for manufacturer in manufacturers:
+        output_file.write("\n")
+        output_file.write("# %s\n" % manufacturer)
+
+        # 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']))
+
+    output_file.write("\n")
+
+def main():
+    """
+    Generate every thing
+    """
+    path = "ccid/readers/"
+    output_file = open("supported_readers.txt", "w")
+
+    supported_readers = parse_ini(path, "supported")
+    shouldwork_readers = parse_ini(path, "shouldwork")
+    unsupported_readers = parse_ini(path, "unsupported")
+    disabled_readers = parse_ini(path, "disabled")
+
+    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)
+    output_file.close()
+
+if __name__ == "__main__":
+    main()

Propchange: website/generate_supported_readers.py
------------------------------------------------------------------------------
    svn:keywords = Id




More information about the Pcsclite-cvs-commit mailing list