forked from LudovicRousseau/PCSC-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plist2txt.py
executable file
·53 lines (43 loc) · 1.74 KB
/
plist2txt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# plist2txt.py: convert a Info.plist file to a text list
# Copyright (C) 2016 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.
# Usage:
# ./plist2txt.py /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
from __future__ import print_function
import plistlib
import sys
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))
if __name__ == "__main__":
convert(sys.argv[1])