Skip to content

Add warning for out-of-bounds page range in pdfly cat command#58

Merged
Lucas-C merged 3 commits intopy-pdf:mainfrom
Zingzy:warning-on-missing-pages
Oct 8, 2024
Merged

Add warning for out-of-bounds page range in pdfly cat command#58
Lucas-C merged 3 commits intopy-pdf:mainfrom
Zingzy:warning-on-missing-pages

Conversation

@Zingzy
Copy link
Copy Markdown
Contributor

@Zingzy Zingzy commented Oct 6, 2024

PR Description

This PR addresses issue #33 where users attempting to use the pdfly cat command to extract a range of pages outside the number of pages in the PDF document do not receive a warning. The following changes have been made:

  • Implemented a warning message: Added logic to check if the specified page range is out of bounds and print a warning to stderr if it is.
  • Removed the pytest.skip decorator from the test case: Enabled the test_cat_subset_warn_on_missing_pages test to verify the warning message in stderr.

Testing

  • Ran the updated test suite to ensure that the warning message is correctly produced and captured.
  • Verified that the test_cat_subset_warn_on_missing_pages test passes, confirming that the warning is printed to stderr when the page range is out of bounds.
@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Oct 7, 2024

Hi @Zingzy

This looks great, thank your for your contribution 👍

Could you just run black pdfly/cat.py and include the changes in this PR?
Currently the GitHub Actions pipeline fails because this code formatter has not been applied to this file following your changes:
https://github.com/py-pdf/pdfly/actions/runs/11204446524/job/31171421427?pr=58

@Zingzy
Copy link
Copy Markdown
Contributor Author

Zingzy commented Oct 7, 2024

Hello @Lucas-C, I made the necessary changes. 😄

@Zingzy
Copy link
Copy Markdown
Contributor Author

Zingzy commented Oct 8, 2024

Hello @Lucas-C any updates on this?

@Lucas-C Lucas-C merged commit 1aefb3a into py-pdf:main Oct 8, 2024
@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Oct 8, 2024

I merged your MR!

Thank you very much for your contribution @Zingzy 👍

ebotiab pushed a commit to ebotiab/pdfly that referenced this pull request Oct 15, 2024
MartinThoma added a commit that referenced this pull request Dec 8, 2024
## What's new

### New Features (ENH)
- New `booklet` command to adjust offsets and lengths ([PR #77](#77))
- New `uncompress` command ([PR #75](#75))
- New `update-offsets` command to adjust offsets and lengths ([PR #15](#15))
- New `rm` command ([PR #59](#59))
- `metadata`: now also displaying CreationDate, Creator, Keywords & Subject ([PR #73](#73))
- Add warning for out-of-bounds page range in pdfly `cat` command ([PR #58](#58))

### Bug Fixes (BUG)
- `2-up` command, that only showed one page per sheet, on the left side, with blank space on the right ([PR #78](#78))

[Full Changelog](0.3.3...0.4.0)
@Lucas-C
Copy link
Copy Markdown
Member

Lucas-C commented Dec 8, 2024

This has been released in version 0.4.0: https://pypi.org/project/pdfly/#history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment