diff --git a/CHANGELOG.md b/CHANGELOG.md index 292125f..d69adbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.8.0] - 2020-10-08 + +### Changed +- Replaced `plistlib.readPlist()` with `plistlib.load()` + + ## [1.7.0] - 2020-10-06 ### Added @@ -188,8 +194,9 @@ All notable changes to this project will be documented in this file. This projec - Initial release -[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.7.0...HEAD -[1.6.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.2...v1.7.0 +[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.8.0...HEAD +[1.8.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.7.0...v1.8.0 +[1.7.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.2...v1.7.0 [1.6.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.1...v1.6.2 [1.6.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.0...v1.6.1 [1.6.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.5.2...v1.6.0 diff --git a/README.md b/README.md index 7bd48c1..d2bad58 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.7.0 + rev: v1.8.0 hooks: - id: check-plists # - id: ... @@ -119,7 +119,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.7.0 + rev: v1.8.0 hooks: - id: check-munki-pkgsinfo args: ['--catalogs', 'testing', 'stable', '--'] @@ -129,7 +129,7 @@ But if you also use the `--categories` argument, you would move the trailing `-- ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.7.0 + rev: v1.8.0 hooks: - id: check-munki-pkgsinfo args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--'] @@ -141,7 +141,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.7.0 + rev: v1.8.0 hooks: - id: check-munki-pkgsinfo args: [ diff --git a/pre_commit_hooks/check_autopkg_recipe_list.py b/pre_commit_hooks/check_autopkg_recipe_list.py index a45f949..048994a 100755 --- a/pre_commit_hooks/check_autopkg_recipe_list.py +++ b/pre_commit_hooks/check_autopkg_recipe_list.py @@ -7,9 +7,10 @@ """ import argparse +import json import plistlib from xml.parsers.expat import ExpatError -import json + import ruamel.yaml yaml = ruamel.yaml.YAML(typ="safe") @@ -44,7 +45,8 @@ def main(argv=None): ] elif filename.endswith(".plist"): try: - recipe_list = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + recipe_list = plistlib.load(openfile) except (ExpatError, ValueError) as err: print("{}: plist parsing error: {}".format(filename, err)) retval = 1 diff --git a/pre_commit_hooks/check_autopkg_recipes.py b/pre_commit_hooks/check_autopkg_recipes.py index 64eb8b9..b9d79d7 100755 --- a/pre_commit_hooks/check_autopkg_recipes.py +++ b/pre_commit_hooks/check_autopkg_recipes.py @@ -383,7 +383,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - recipe = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + recipe = plistlib.load(openfile) except (ExpatError, ValueError) as err: print("{}: plist parsing error: {}".format(filename, err)) diff --git a/pre_commit_hooks/check_jamf_profiles.py b/pre_commit_hooks/check_jamf_profiles.py index 3418d5d..7388935 100644 --- a/pre_commit_hooks/check_jamf_profiles.py +++ b/pre_commit_hooks/check_jamf_profiles.py @@ -27,7 +27,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - profile = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + profile = plistlib.load(openfile) except (ExpatError, ValueError) as err: print("{}: plist parsing error: {}".format(filename, err)) retval = 1 diff --git a/pre_commit_hooks/check_munki_pkgsinfo.py b/pre_commit_hooks/check_munki_pkgsinfo.py index 74226a4..e9d2b8a 100755 --- a/pre_commit_hooks/check_munki_pkgsinfo.py +++ b/pre_commit_hooks/check_munki_pkgsinfo.py @@ -49,7 +49,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - pkginfo = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + pkginfo = plistlib.load(openfile) except (ExpatError, ValueError) as err: print("{}: plist parsing error: {}".format(filename, err)) retval = 1 @@ -180,7 +181,7 @@ def main(argv=None): if script_type in pkginfo: if all(not pkginfo[script_type].startswith(x + "\n") for x in shebangs): print( - "{}: has a {} that does not start with a valid shebang.".format( + "{}: Has a {} that does not start with a valid shebang.".format( filename, script_type ) ) diff --git a/pre_commit_hooks/check_munkipkg_buildinfo.py b/pre_commit_hooks/check_munkipkg_buildinfo.py index cbdca13..cab4bf7 100755 --- a/pre_commit_hooks/check_munkipkg_buildinfo.py +++ b/pre_commit_hooks/check_munkipkg_buildinfo.py @@ -81,7 +81,8 @@ def main(argv=None): for filename in args.filenames: if filename.endswith(".plist"): try: - buildinfo = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + buildinfo = plistlib.load(openfile) except (ExpatError, ValueError) as err: print("{}: plist parsing error: {}".format(filename, err)) retval = 1 diff --git a/pre_commit_hooks/check_plists.py b/pre_commit_hooks/check_plists.py index 40736a7..4a4fd9d 100755 --- a/pre_commit_hooks/check_plists.py +++ b/pre_commit_hooks/check_plists.py @@ -27,7 +27,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - plist = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + plist = plistlib.load(openfile) # Possible future addition, but disabled for now. # if not isinstance(plist, dict): # print("{}: top level of plist should be type dict".format(filename)) diff --git a/pre_commit_hooks/forbid_autopkg_overrides.py b/pre_commit_hooks/forbid_autopkg_overrides.py index bd8ebb7..d7331c2 100755 --- a/pre_commit_hooks/forbid_autopkg_overrides.py +++ b/pre_commit_hooks/forbid_autopkg_overrides.py @@ -30,7 +30,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - recipe = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + recipe = plistlib.load(openfile) for req_key in required_keys: if req_key not in recipe: print("{}: possible AutoPkg recipe override".format(filename)) diff --git a/pre_commit_hooks/forbid_autopkg_trust_info.py b/pre_commit_hooks/forbid_autopkg_trust_info.py index 322c269..0f51730 100644 --- a/pre_commit_hooks/forbid_autopkg_trust_info.py +++ b/pre_commit_hooks/forbid_autopkg_trust_info.py @@ -28,7 +28,8 @@ def main(argv=None): retval = 0 for filename in args.filenames: try: - recipe = plistlib.readPlist(filename) + with open(filename, "rb") as openfile: + recipe = plistlib.load(openfile) if "ParentRecipeTrustInfo" in recipe: print("{}: trust info in recipe".format(filename)) retval = 1 diff --git a/setup.py b/setup.py index c0908d3..638e546 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name="pre-commit-macadmin", description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.", url="https://github.com/homebysix/pre-commit-macadmin", - version="1.7.0", + version="1.8.0", author="Elliot Jordan", author_email="elliot@elliotjordan.com", packages=["pre_commit_hooks"],