1
+ #!/usr/local/bin/managed_python3
2
+
1
3
import argparse
2
4
import string
3
5
import os
4
6
import subprocess
5
7
import tempfile
6
8
import shutil
7
9
import stat
10
+ import plistlib
8
11
9
12
#
10
13
# quickpkg
@@ -142,7 +145,7 @@ def finditemswithextension(dirpath, item_extension):
142
145
if os.path.exists(dirpath):
143
146
for x in os.listdir(dirpath):
144
147
(item_basename, item_extension) = os.path.splitext(x)
145
- item_extension = string .lstrip(item_extension, '.')
148
+ item_extension = item_extension .lstrip('.')
146
149
if item_extension == 'app':
147
150
foundapps.append(os.path.join(dirpath, x))
148
151
else:
@@ -157,7 +160,8 @@ def appNameAndVersion(app_path):
157
160
print("Application at path %s does not have Info.plist" % app_path)
158
161
# TODO: cleanup volumes here
159
162
cleanup_and_exit(1)
160
- info_plist = readPlist(info_path)
163
+ with open(info_path, 'rb') as info_file:
164
+ info_plist = plistlib.load(info_file)
161
165
app_name = info_plist.get("CFBundleName")
162
166
if app_name is None:
163
167
app_name = info_plist.get("CFBundleDisplayName")
@@ -234,15 +238,15 @@ if __name__ == "__main__":
234
238
args = parser.parse_args()
235
239
236
240
# remove trailing '/' from path
237
- item_path = string.rstrip( args.item_path, '/')
241
+ item_path = args.item_path.rstrip( '/')
238
242
239
243
if item_path.startswith('~'):
240
244
item_path = os.path.expanduser(item_path)
241
245
item_path = os.path.abspath(item_path)
242
246
243
247
# get file extension
244
248
(item_basename, item_extension) = os.path.splitext(item_path)
245
- item_extension = string .lstrip(item_extension, '.')
249
+ item_extension = item_extension .lstrip('.')
246
250
247
251
# is extension supported
248
252
if item_extension not in supported_extensions:
@@ -358,12 +362,14 @@ if __name__ == "__main__":
358
362
359
363
if not args.relocatable:
360
364
# read and change component plist
361
- components = readPlist(component_plist)
365
+ with open(component_plist, 'rb') as component_file:
366
+ components = plistlib.load(component_file)
362
367
# component plist is an array of components
363
368
for bundle in components:
364
369
if "BundleIsRelocatable" in list(bundle.keys()):
365
370
bundle["BundleIsRelocatable"] = False
366
- writePlist(components, component_plist)
371
+ with open(component_plist, 'wb') as component_file:
372
+ plistlib.dump(components, component_file, fmt=plistlib.FMT_XML)
367
373
368
374
pkg_name = "{name}-{version}.pkg"
369
375
if args.output:
0 commit comments