| 21 |
import os |
import os |
| 22 |
import ConfigParser |
import ConfigParser |
| 23 |
import pprint |
import pprint |
| 24 |
|
import templayer |
| 25 |
|
import time |
| 26 |
|
|
| 27 |
pp = pprint.PrettyPrinter(indent=4) |
pp = pprint.PrettyPrinter(indent=4) |
| 28 |
|
|
| 63 |
parse a foobas.ini file to extract all informations |
parse a foobas.ini file to extract all informations |
| 64 |
""" |
""" |
| 65 |
config = ConfigParser.ConfigParser() |
config = ConfigParser.ConfigParser() |
| 66 |
|
# do not use the default case insensitive transform for key value |
| 67 |
|
config.optionxform = str |
| 68 |
config.read(inifile) |
config.read(inifile) |
| 69 |
reader_list = config.sections() |
reader_list = config.sections() |
| 70 |
|
|
| 97 |
if len(real_list) > 0: |
if len(real_list) > 0: |
| 98 |
raise Exception("readers %s are not listed" % real_list) |
raise Exception("readers %s are not listed" % real_list) |
| 99 |
|
|
| 100 |
|
def get_by_manufacturer(readers): |
| 101 |
|
d = {} |
| 102 |
|
for r in readers.keys(): |
| 103 |
|
d.setdefault(readers[r]['iManufacturer'], []).append(r) |
| 104 |
|
return d |
| 105 |
|
|
| 106 |
if __name__ == "__main__": |
if __name__ == "__main__": |
| 107 |
path = "../trunk/Drivers/ccid/readers/" |
path = "../trunk/Drivers/ccid/readers/" |
| 108 |
|
|
| 114 |
#pp.pprint(reader_list) |
#pp.pprint(reader_list) |
| 115 |
check_list(path, reader_list) |
check_list(path, reader_list) |
| 116 |
|
|
| 117 |
r = "Kobil_EMV_CAP.txt" |
# sort the readers by manufacturers |
| 118 |
#pp.pprint(supported_readers[r].keys()) |
manufacturer_readers = get_by_manufacturer(supported_readers) |
| 119 |
|
manufacturers = list(manufacturer_readers) |
| 120 |
|
manufacturers.sort(key=str.lower) |
| 121 |
|
|
| 122 |
|
r = "Gemalto_PDT.txt" |
| 123 |
|
#pp.pprint(supported_readers[r]) |
| 124 |
for k in supported_readers[r].keys(): |
for k in supported_readers[r].keys(): |
| 125 |
#print k, ":", supported_readers[r][k] |
#print k, ":", supported_readers[r][k] |
| 126 |
pass |
pass |
| 127 |
|
|
| 128 |
|
template = templayer.HTMLTemplate("supported.template") |
| 129 |
|
file_writer = template.start_file(file=file("supported.html", "w")) |
| 130 |
|
main_layer = file_writer.open(date=time.asctime()) |
| 131 |
|
|
| 132 |
|
# for each manufacturer |
| 133 |
|
for m in manufacturers: |
| 134 |
|
main_layer.write_layer('manufacturer', manufacturer=m) |
| 135 |
|
|
| 136 |
|
# for each reader |
| 137 |
|
for r in sorted(manufacturer_readers[m]): |
| 138 |
|
main_layer.write_layer('reader', |
| 139 |
|
manufacturer=m, |
| 140 |
|
product=supported_readers[r]['iProduct'], |
| 141 |
|
url=supported_readers[r].get('url', ""), |
| 142 |
|
image="img/" + supported_readers[r].get('image', |
| 143 |
|
"no_image.png")) |
| 144 |
|
file_writer.close() |