Skip to content

Modernize pyExtractHEIC: proper package structure, CLI, tests, and CI#3

Merged
johnsirmon merged 3 commits into
mainfrom
copilot/modernize-codebase-structure
Feb 22, 2026
Merged

Modernize pyExtractHEIC: proper package structure, CLI, tests, and CI#3
johnsirmon merged 3 commits into
mainfrom
copilot/modernize-codebase-structure

Conversation

Copilot AI commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

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

  • Inverted extraction logicif not fnmatch(…, "icloud photos/*") extracted files outside the iCloud folder; flipped to if fnmatch(…)
  • Silent cleanup failureos.rmdir() raises on non-empty directories; replaced with shutil.rmtree()
  • Uppercase .HEIC skipped — case-sensitive fnmatch("*.heic") missed iPhone files; lowercased before matching
  • Broken pathsr"\zip" resolved to /zip (filesystem root); replaced with Path(__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 orchestrator process_zip_dir
  • heic_converter/cli.py — argparse CLI with --zip-dir, --extract-dir, --convert-dir, --zip-pattern, -v; invocable as python -m heic_converter
  • ConvertIphonePics.py — retained as a thin shim delegating to the package for backward compatibility

Tooling

  • pyproject.toml — packaging, ruff, and pytest config
  • requirements.txtpip install -r requirements.txt works out of the box
  • .github/workflows/ci.yml — ruff + pytest on every push/PR with permissions: contents: read
  • .gitignore — excludes zip files, artifacts, and the previously committed iCloud Photos (11).zip binary (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.

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
Copilot AI requested a review from johnsirmon February 22, 2026 15:10
@johnsirmon johnsirmon marked this pull request as ready for review February 22, 2026 15:20
@johnsirmon johnsirmon merged commit cb9b28a into main Feb 22, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants