Skip to content

Commit 3879ebb

Browse files
committed
Use plistlib.load() instead of plistlib.readPlist()
1 parent ec6d37c commit 3879ebb

9 files changed

Lines changed: 25 additions & 10 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
44

55

6+
## [1.8.0] - 2020-10-08
7+
8+
### Changed
9+
- Replaced `plistlib.readPlist()` with `plistlib.load()`
10+
11+
612
## [1.7.0] - 2020-10-06
713

814
### Added

pre_commit_hooks/check_autopkg_recipe_list.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"""
88

99
import argparse
10+
import json
1011
import plistlib
1112
from xml.parsers.expat import ExpatError
12-
import json
13+
1314
import ruamel.yaml
1415

1516
yaml = ruamel.yaml.YAML(typ="safe")
@@ -44,7 +45,8 @@ def main(argv=None):
4445
]
4546
elif filename.endswith(".plist"):
4647
try:
47-
recipe_list = plistlib.readPlist(filename)
48+
with open(filename, "rb") as openfile:
49+
recipe_list = plistlib.load(openfile)
4850
except (ExpatError, ValueError) as err:
4951
print("{}: plist parsing error: {}".format(filename, err))
5052
retval = 1

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ def main(argv=None):
383383
retval = 0
384384
for filename in args.filenames:
385385
try:
386-
recipe = plistlib.readPlist(filename)
386+
with open(filename, "rb") as openfile:
387+
recipe = plistlib.load(openfile)
387388

388389
except (ExpatError, ValueError) as err:
389390
print("{}: plist parsing error: {}".format(filename, err))

pre_commit_hooks/check_jamf_profiles.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def main(argv=None):
2727
retval = 0
2828
for filename in args.filenames:
2929
try:
30-
profile = plistlib.readPlist(filename)
30+
with open(filename, "rb") as openfile:
31+
profile = plistlib.load(openfile)
3132
except (ExpatError, ValueError) as err:
3233
print("{}: plist parsing error: {}".format(filename, err))
3334
retval = 1

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def main(argv=None):
4949
retval = 0
5050
for filename in args.filenames:
5151
try:
52-
pkginfo = plistlib.readPlist(filename)
52+
with open(filename, "rb") as openfile:
53+
pkginfo = plistlib.load(openfile)
5354
except (ExpatError, ValueError) as err:
5455
print("{}: plist parsing error: {}".format(filename, err))
5556
retval = 1
@@ -180,7 +181,7 @@ def main(argv=None):
180181
if script_type in pkginfo:
181182
if all(not pkginfo[script_type].startswith(x + "\n") for x in shebangs):
182183
print(
183-
"{}: has a {} that does not start with a valid shebang.".format(
184+
"{}: Has a {} that does not start with a valid shebang.".format(
184185
filename, script_type
185186
)
186187
)

pre_commit_hooks/check_munkipkg_buildinfo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def main(argv=None):
8181
for filename in args.filenames:
8282
if filename.endswith(".plist"):
8383
try:
84-
buildinfo = plistlib.readPlist(filename)
84+
with open(filename, "rb") as openfile:
85+
buildinfo = plistlib.load(openfile)
8586
except (ExpatError, ValueError) as err:
8687
print("{}: plist parsing error: {}".format(filename, err))
8788
retval = 1

pre_commit_hooks/check_plists.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def main(argv=None):
2727
retval = 0
2828
for filename in args.filenames:
2929
try:
30-
plist = plistlib.readPlist(filename)
30+
with open(filename, "rb") as openfile:
31+
plist = plistlib.load(openfile)
3132
# Possible future addition, but disabled for now.
3233
# if not isinstance(plist, dict):
3334
# print("{}: top level of plist should be type dict".format(filename))

pre_commit_hooks/forbid_autopkg_overrides.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def main(argv=None):
3030
retval = 0
3131
for filename in args.filenames:
3232
try:
33-
recipe = plistlib.readPlist(filename)
33+
with open(filename, "rb") as openfile:
34+
recipe = plistlib.load(openfile)
3435
for req_key in required_keys:
3536
if req_key not in recipe:
3637
print("{}: possible AutoPkg recipe override".format(filename))

pre_commit_hooks/forbid_autopkg_trust_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def main(argv=None):
2828
retval = 0
2929
for filename in args.filenames:
3030
try:
31-
recipe = plistlib.readPlist(filename)
31+
with open(filename, "rb") as openfile:
32+
recipe = plistlib.load(openfile)
3233
if "ParentRecipeTrustInfo" in recipe:
3334
print("{}: trust info in recipe".format(filename))
3435
retval = 1

0 commit comments

Comments
 (0)