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

ENH: Add reader.attachments public interface #1661

Merged
merged 6 commits into from
Feb 26, 2023
Merged

Conversation

MartinThoma
Copy link
Member

@MartinThoma MartinThoma commented Feb 25, 2023

Add PdfReader.attachments -> Mapping[str, List[bytes]] as a public interface.

The heavy-lifting was done by @pubpub-zz in #1611

@MartinThoma
Copy link
Member Author

@pubpub-zz What do you think about this public interface to the _get_attachments / _list_attachments methods?

@MartinThoma
Copy link
Member Author

MartinThoma commented Feb 25, 2023

I'm not sure if I like the LazyLoader. I would like to hide this lazy-loading behaviour. Essentially only load it, if the key of the dictionary is accessed (while still keeping it a standard dictionary with the keys / values / items methods + the index accessing.

@MasterOdin do you maybe have an idea?

edit: https://stackoverflow.com/a/47212782/562769 might be working 🤔

@codecov
Copy link

codecov bot commented Feb 25, 2023

Codecov Report

Base: 92.26% // Head: 92.28% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (c7accb5) compared to base (44bc1fc).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1661      +/-   ##
==========================================
+ Coverage   92.26%   92.28%   +0.02%     
==========================================
  Files          33       33              
  Lines        6439     6457      +18     
  Branches     1290     1292       +2     
==========================================
+ Hits         5941     5959      +18     
  Misses        315      315              
  Partials      183      183              
Impacted Files Coverage Δ
pypdf/_reader.py 90.88% <100.00%> (+0.17%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MartinThoma
Copy link
Member Author

@pubpub-zz what do you think about this pr?

Copy link
Collaborator

@pubpub-zz pubpub-zz left a comment

Choose a reason for hiding this comment

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

sounds pretty good, just a couple of comments

tests/test_writer.py Show resolved Hide resolved
tests/test_writer.py Show resolved Hide resolved
@pubpub-zz
Copy link
Collaborator

All good for me! 👏

@MartinThoma MartinThoma merged commit d343445 into main Feb 26, 2023
@MartinThoma MartinThoma deleted the attachments-interface branch February 26, 2023 16:04
@MartinThoma
Copy link
Member Author

Nice!

I also just understood your comment - I had initially a worse interface that was still in the top of the PR. I've adjusted the message in the top :-)

MartinThoma added a commit that referenced this pull request Feb 26, 2023
New Features (ENH)
-  Add reader.attachments public interface (#1611, #1661)
-  Add PdfWriter.remove_objects_from_page(page: PageObject, to_delete: ObjectDeletionFlag) (#1648)
-  Allow free-text annotation to have transparent border/background (#1664)

Bug Fixes (BUG)
-  Allow decryption with empty password for AlgV5 (#1663)
-  Let PdfWriter.pages return PageObject after calling `clone_document_from_reader()` (#1613)
-  Invalid font pointed during merge_resources (#1641)

Robustness (ROB)
-  Cope with invalid objects in IndirectObject.clone (#1637)
-  Improve tolerance to invalid Names/Dests (#1658)
-  Decode encoded values in get_fields (#1636)
-  Let PdfWriter.merge cope with missing "/Fields" (#1628)

[Full Changelog](3.4.1...3.5.0)
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