Skip to content

Commit

Permalink
plist2txt.py: check the 3 arrays have the same size
Browse files Browse the repository at this point in the history
If the 3 arrays ifdVendorID, ifdProductID and ifdFriendlyName had
different sizes then the program did not complained.
  • Loading branch information
LudovicRousseau committed Jan 25, 2017
1 parent fa33161 commit cc89afe
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plist2txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Usage:
# ./plist2txt.py /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist

from __future__ import print_function

import plistlib
import sys
Expand All @@ -32,10 +33,21 @@ def convert(filename):
root = plistlib.readPlist(filename)
# for key in root:
# print key

n_ifdVendorID = len(root['ifdVendorID'])
n_ifdProductID = len(root['ifdProductID'])
n_ifdFriendlyName = len(root['ifdFriendlyName'])
if n_ifdVendorID != n_ifdProductID or n_ifdVendorID != n_ifdFriendlyName:
print("Error: wrongs sizes")
print("ifdVendorID:", n_ifdVendorID)
print("ifdProductID:", n_ifdProductID)
print("ifdFriendlyName:", n_ifdFriendlyName)
return

zipped = zip(root['ifdVendorID'], root['ifdProductID'],
root['ifdFriendlyName'])
for elt in sorted(zipped):
print ":".join(elt)
print(":".join(elt))

if __name__ == "__main__":
convert(sys.argv[1])

0 comments on commit cc89afe

Please sign in to comment.