diff --git a/CHANGELOG.md b/CHANGELOG.md index e48f4e0..3a52cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file. This projec Changes since last release will be listed here. +## [v0.6.3] - 2022-06-21 - v0.6.3 + +- Fixed running on folders without a destination when converting from YAML to PLIST or vice versa. + ## [v0.6.1] - 2021-04-26 - v0.6.1 - Adding `ParentRecipeTrustInfo` to the `desired_order` dict so that when autopkg recipes are converted or tidied, the Trust Info is retained. Also adding this to the processors which gain a new line before them for readability (#10 - thanks to @smithjw). @@ -52,7 +56,8 @@ Changes since last release will be listed here. - Initial Release (though the tool has been around for some time). -[unreleased]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.6.1...HEAD +[unreleased]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.6.3...HEAD +[v0.6.3]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.6.1...v0.6.3 [v0.6.1]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.6.0...v0.6.1 [v0.6.0]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.5.0...v0.6.0 [v0.5.0]: https://github.com/grahampugh/plist-yaml-plist/compare/v0.4.0...v0.5.0 diff --git a/Makefile b/Makefile index 8f8d81f..efcaeed 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ $($(CURDIR)/versionbump.py) CURDIR := $(shell pwd) MUNKIPKG := /usr/local/bin/munkipkg +PYTHON_PATH := /usr/local/autopkg/python PKG_ROOT := $(CURDIR)/pkg/plistyamlplist/payload PKG_BUILD := $(CURDIR)/pkg/plistyamlplist/build PKG_VERSION := $(shell defaults read $(CURDIR)/pkg/plistyamlplist/build-info.plist version) @@ -15,7 +16,7 @@ default : $(PKG_BUILD)/plistyamlplist-$(PKG_VERSION).pkg $(PKG_BUILD)/plistyamlplist-$(PKG_VERSION).pkg: $(objects) - cd $(CURDIR)/pkg && $(MUNKIPKG) plistyamlplist + cd $(CURDIR)/pkg && $(PYTHON_PATH) $(MUNKIPKG) plistyamlplist open $(CURDIR)/pkg/plistyamlplist/build diff --git a/pkg/plistyamlplist/build-info.plist b/pkg/plistyamlplist/build-info.plist index 77c4df2..7344c5e 100644 --- a/pkg/plistyamlplist/build-info.plist +++ b/pkg/plistyamlplist/build-info.plist @@ -9,7 +9,7 @@ install_location / name - plistyamlplist-0.6.2.pkg + plistyamlplist-0.6.3.pkg ownership recommended postinstall_action @@ -17,6 +17,6 @@ suppress_bundle_relocation version - 0.6.2 + 0.6.3 diff --git a/plistyamlplist.py b/plistyamlplist.py index 7da814e..60e2513 100755 --- a/plistyamlplist.py +++ b/plistyamlplist.py @@ -198,48 +198,51 @@ def main(): elif os.path.isdir(in_path) and "YAML" in in_path: print("Processing YAML folder...") filetype = "yaml" - if sys.argv[2] == "--tidy": - print("WARNING! Processing all subfolders...\n") - for root, dirs, files in os.walk(in_path): - for name in files: - tidy_yaml(os.path.join(root, name)) - for name in dirs: - tidy_yaml(os.path.join(root, name)) - elif os.path.isdir(sys.argv[2]): - # allow batch replication of folder structure and conversion of yaml to plist - # also copies other file types without conversion to the same place in the - # hierarchy - out_path_base = os.path.abspath(sys.argv[2]) - print("Writing to {}".format(out_path_base)) - for root, dirs, files in os.walk(in_path): - for name in dirs: - working_dir = os.path.join(out_path_base, name) - if not os.path.isdir(working_dir): - print("Creating new folder " + working_dir) - os.mkdir(working_dir) - for name in files: - source_path = os.path.join(root, name) - print("In path: " + in_path) - sub_path = re.sub(in_path, "", source_path) - print("Subdirectory path: " + sub_path) - filename, _ = os.path.splitext( - os.path.join(out_path_base, sub_path) - ) - print("Source path: " + source_path) - if source_path.endswith(".yaml"): - dest_path = filename + ".plist" - print("Destination path for plist: " + dest_path) - yaml_plist(source_path, dest_path) - else: - dest_path = os.path.join(os.path.join(out_path_base, sub_path)) - print("Destination path: " + dest_path) - try: - shutil.copy(source_path, dest_path) - if os.path.isfile(dest_path): - print("Written to " + dest_path + "\n") - except IOError: - print("ERROR: could not copy " + source_path + "\n") - else: + try: + if sys.argv[2] == "--tidy": + print("WARNING! Processing all subfolders...\n") + for root, dirs, files in os.walk(in_path): + for name in files: + tidy_yaml(os.path.join(root, name)) + for name in dirs: + tidy_yaml(os.path.join(root, name)) + elif os.path.isdir(sys.argv[2]): + # allow batch replication of folder structure and conversion of yaml to plist + # also copies other file types without conversion to the same place in the + # hierarchy + out_path_base = os.path.abspath(sys.argv[2]) + print("Writing to {}".format(out_path_base)) + for root, dirs, files in os.walk(in_path): + for name in dirs: + working_dir = os.path.join(out_path_base, name) + if not os.path.isdir(working_dir): + print("Creating new folder " + working_dir) + os.mkdir(working_dir) + for name in files: + source_path = os.path.join(root, name) + print("In path: " + in_path) + sub_path = re.sub(in_path, "", source_path) + print("Subdirectory path: " + sub_path) + filename, _ = os.path.splitext( + os.path.join(out_path_base, sub_path) + ) + print("Source path: " + source_path) + if source_path.endswith(".yaml"): + dest_path = filename + ".plist" + print("Destination path for plist: " + dest_path) + yaml_plist(source_path, dest_path) + else: + dest_path = os.path.join( + os.path.join(out_path_base, sub_path) + ) + print("Destination path: " + dest_path) + try: + shutil.copy(source_path, dest_path) + if os.path.isfile(dest_path): + print("Written to " + dest_path + "\n") + except IOError: + print("ERROR: could not copy " + source_path + "\n") + except IndexError: for in_file in os.listdir(in_path): in_file_path = os.path.join(in_path, in_file) out_path = get_out_path(in_file_path, filetype) diff --git a/plistyamlplist_lib/version.py b/plistyamlplist_lib/version.py index 1bb2ae1..63af887 100644 --- a/plistyamlplist_lib/version.py +++ b/plistyamlplist_lib/version.py @@ -1 +1 @@ -__version__ = "0.6.2" \ No newline at end of file +__version__ = "0.6.3"