Modernize pyExtractHEIC: proper package structure, CLI, tests, and CI#3
Merged
Merged
Conversation
Co-authored-by: johnsirmon <11774402+johnsirmon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor and improve codebase for better maintainability
Modernize pyExtractHEIC: proper package structure, CLI, tests, and CI
Feb 22, 2026
johnsirmon
approved these changes
Feb 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original codebase was a single script with several correctness bugs, hardcoded broken paths, no tests, and no CI. This PR refactors it into a maintainable Python package.
Bug fixes
if not fnmatch(…, "icloud photos/*")extracted files outside the iCloud folder; flipped toif fnmatch(…)os.rmdir()raises on non-empty directories; replaced withshutil.rmtree().HEICskipped — case-sensitivefnmatch("*.heic")missed iPhone files; lowercased before matchingr"\zip"resolved to/zip(filesystem root); replaced withPath(__file__).parent / "zip"Package restructure
heic_converter/converter.py— decomposed into three independently testable functions:extract_heic_from_zip,convert_heic_to_png,convert_directory, and an orchestratorprocess_zip_dirheic_converter/cli.py— argparse CLI with--zip-dir,--extract-dir,--convert-dir,--zip-pattern,-v; invocable aspython -m heic_converterConvertIphonePics.py— retained as a thin shim delegating to the package for backward compatibilityTooling
pyproject.toml— packaging, ruff, and pytest configrequirements.txt—pip install -r requirements.txtworks out of the box.github/workflows/ci.yml— ruff + pytest on every push/PR withpermissions: contents: read.gitignore— excludes zip files, artifacts, and the previously committediCloud Photos (11).zipbinary (removed from working tree)Tests
13 unit tests covering extraction, conversion, end-to-end orchestration, and CLI error handling — including case-insensitive matching, missing directories, empty zips, and non-matching zip patterns.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.