-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MAINT: Move code from _page.py to _text_extraction #3343
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
Conversation
76ca472 to
0214f87
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3343 +/- ##
=======================================
Coverage 96.73% 96.73%
=======================================
Files 53 54 +1
Lines 9060 9069 +9
Branches 1676 1676
=======================================
+ Hits 8764 8773 +9
Misses 177 177
Partials 119 119 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR moves code related to PDF text extraction from _page.py to a dedicated file in _text_extraction to improve maintainability and reduce merge conflicts. Key changes include:
- Moving the implementations of _get_actual_font_widths and _handle_tj into a new TextExtraction class.
- Adding a license preamble and creating a new file (pypdf/_text_extraction/_text_extractor.py) to house the extracted methods.
- Updating _page.py to remove duplicate logic and use the new TextExtraction instance.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pypdf/_text_extraction/_text_extractor.py | New file with the TextExtraction class and moved text extraction logic. |
| pypdf/_page.py | Removed duplicate extraction functions and updated calls to use the new TextExtraction class. |
stefan6419846
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did a quick check myself and the diff looks correct.
The goal of this PR is to increase maintainabilty by reducing the size of __page.py. This helps, because:
It also prepares for a big more complex refactoring (see #3339 )
For the Reviewer
This PR is almost only copy-paste (moving the location of the code, but no additions/changes):
_get_actual_font_widthsand_handle_tjwere only moved