|
1 | 1 | #!/usr/bin/python
|
2 |
| -import os |
3 |
| -from plistlib import readPlist, writePlist |
4 |
| -import csv |
| 2 | +from __future__ import absolute_import, print_function |
| 3 | + |
5 | 4 | import argparse
|
6 |
| -import sys |
| 5 | +import csv |
| 6 | +import os |
7 | 7 | import re
|
| 8 | +import sys |
| 9 | + |
| 10 | +try: |
| 11 | + from plistlib import load as load_plist # Python 3 |
| 12 | + from plistlib import dump as dump_plist |
| 13 | +except ImportError: |
| 14 | + from plistlib import readPlist as load_plist # Python 2 |
| 15 | + from plistlib import writePlist as dump_plist |
| 16 | + |
8 | 17 |
|
9 | 18 | def getOptionsString(optionList):
|
10 | 19 | # optionList should be a list item
|
@@ -33,7 +42,7 @@ def getOptionsString(optionList):
|
33 | 42 |
|
34 | 43 | pwd = os.path.dirname(os.path.realpath(__file__))
|
35 | 44 | f = open(os.path.join(pwd, 'AddPrinter-Template.plist'), 'rb')
|
36 |
| -templatePlist = readPlist(f) |
| 45 | +templatePlist = load_plist(f) |
37 | 46 | f.close()
|
38 | 47 |
|
39 | 48 | if args.csv:
|
@@ -101,7 +110,7 @@ def getOptionsString(optionList):
|
101 | 110 | # Write out the file
|
102 | 111 | newFileName = "AddPrinter-" + row[0] + "-" + version + ".pkginfo"
|
103 | 112 | f = open(newFileName, 'wb')
|
104 |
| - writePlist(newPlist, f) |
| 113 | + dump_plist(newPlist, f) |
105 | 114 | f.close()
|
106 | 115 | else:
|
107 | 116 | if not args.printername:
|
@@ -201,5 +210,5 @@ def getOptionsString(optionList):
|
201 | 210 |
|
202 | 211 | newFileName = "AddPrinter-" + str(args.printername) + "-%s.pkginfo" % str(version)
|
203 | 212 | f = open(newFileName, 'wb')
|
204 |
| - writePlist(newPlist, f) |
| 213 | + dump_plist(newPlist, f) |
205 | 214 | f.close()
|
0 commit comments