Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing a pypdf CLI program - close #2160 #2170

Closed
wants to merge 3 commits into from
Closed

Conversation

Lucas-C
Copy link
Member

@Lucas-C Lucas-C commented Sep 7, 2023

What's missing:

  • maybe more tests?
  • a dedicated documentation page?

@Lucas-C Lucas-C changed the title Introducing a pypdf CLI program Introducing a pypdf CLI program - close #2160 Sep 7, 2023
@Lucas-C Lucas-C requested a review from pubpub-zz September 7, 2023 17:30
@@ -847,7 +847,7 @@ def bits2byte(data: bytes, size: Tuple[int, int], bits: int) -> bytes:
lookup: Any
base: Any
hival: Any
if isinstance(color_space, ArrayObject) and color_space[0] == "/Indexed":
if isinstance(color_space, ArrayObject) and len(color_space) == 4 and color_space[0] == "/Indexed":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this change related to the CLI?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fixup for a bug.

Introducing this CLI and the related unit tests revealed this issue:

  File "/opt/pypdf/pypdf/filters.py", line 851, in _handle_flate
    color_space, base, hival, lookup = (
ValueError: not enough values to unpack (expected 4, got 3)

There is also another bug spotted there:
https://github.com/py-pdf/pypdf/blob/issue-2160/tests/test_cli.py#L91

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lucas-C
can you provide the pdf showing the issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is one of py-pdf test samples: https://github.com/py-pdf/pypdf/blob/main/resources/AutoCad_Diagram.pdf

The error was raised by simply calling pypdf extract-images AutoCad_Diagram.pdf

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reported the 2nd bug there: #2176

Should I open a distinct issue for the 1st bug, regarding filters.py & color_space?

@Lucas-C
Copy link
Member Author

Lucas-C commented Sep 7, 2023

This PR can probably be closed, given that https://github.com/py-pdf/pdfly offers similar functionalities

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage: 98.66% and project coverage change: +0.04% 🎉

Comparison is base (05f2a65) 94.25% compared to head (cdc7139) 94.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2170      +/-   ##
==========================================
+ Coverage   94.25%   94.29%   +0.04%     
==========================================
  Files          42       43       +1     
  Lines        7556     7630      +74     
  Branches     1487     1499      +12     
==========================================
+ Hits         7122     7195      +73     
  Misses        266      266              
- Partials      168      169       +1     
Files Changed Coverage Δ
pypdf/__main__.py 98.64% <98.64%> (ø)
pypdf/filters.py 94.52% <100.00%> (ø)

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@MartinThoma
Copy link
Member

I will not merge the change done with __main__ as pypdf should not become an application. We have pdfly for that.

However, the change to filters and maybe a part of the test looks unrelated / might be interesting to merge. Do you want to (1) adjust the PR or (2) open a new PR or (3) should I take care of it?

@MartinThoma
Copy link
Member

@Lucas-C How should we continue with this PR?

@MartinThoma
Copy link
Member

@Lucas-C Friendly reminder :-) How do you want to continue with this PR?

@MartinThoma
Copy link
Member

I'm closing this PR as I assume that this will not have a follow-up. If I'm wrong, we can still re-open :-)

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.

4 participants