Skip to content

Conversation

@PRAZPC
Copy link
Member

@PRAZPC PRAZPC commented Dec 8, 2025

Pull Request Template

What have you Changed

  • Migrated the project from PyPDF2 to pypdf, replacing deprecated imports and updating PDF-handling code accordingly.
    Updated the code to use the modern PdfReader API.
  • Removed/cleaned up the obsolete mobi_to_json test case, which remained in the test suite even though the function was removed from the codebase.
  • Verified that all tests pass successfully after the migration and cleanup.

Issue no.(must) - #87

Self Check(Tick After Making pull Request)

  • One Change in one Pull Request
  • I am following clean code and Documentation and my code is well linted with flake8.

Join Us on Discord:- https://discord.gg/JfbK3bS

Copy link
Member

@codeperfectplus codeperfectplus left a comment

Choose a reason for hiding this comment

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

Thanks for improving the audiobook.

@codeperfectplus codeperfectplus added enhancement New feature or request python Pull requests that update python code labels Dec 9, 2025
Copy link
Contributor

Copilot AI left a 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 modernizes the PDF handling library by migrating from the deprecated PyPDF2 to its actively maintained successor pypdf. The migration updates the dependency, refactors all PDF-related code to use the new API, and cleans up an obsolete test case for removed mobi functionality.

Key changes:

  • Updated dependency from PyPDF2 3.0.1 to pypdf 4.0.1 with corresponding API migrations (PdfFileReader → PdfReader, method name updates)
  • Renamed PyPDF2DocParser class to PyPDFDocParser to reflect the new library name
  • Removed obsolete mobi_to_json test case that referenced a function no longer in the codebase

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
requirements.txt Updated PDF library dependency from PyPDF2 3.0.1 to pypdf 4.0.1
audiobook/doc_parser/pdf_parser.py Migrated to pypdf API: updated imports, class name, and all method calls (PdfFileReader→PdfReader, numPages→len(pages), getPage→pages[], extractText→extract_text, getOutlines→outline)
audiobook/utils.py Updated import statement to use PyPDFDocParser instead of PyPDF2DocParser
audiobook/main.py Updated logger name from "PyPDF2" to "pypdf" to align with new library
tests/test_create_json_book.py Renamed test from test_pdf_to_json_pypdf2 to test_pdf_to_json_pypdf; commented out obsolete mobi_to_json test
docs/command_line_usage.rst Updated documentation to reference pypdf instead of pypdf2 in extraction engine table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 35 to 36
# def test_docs_to_json(self):
# self.assertEqual(ab.create_json_book("assets/sample.doc"), (output['docs'], {'book_name': 'sample', 'pages': 1}))
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

This comment appears to contain commented-out code.

Suggested change
# def test_docs_to_json(self):
# self.assertEqual(ab.create_json_book("assets/sample.doc"), (output['docs'], {'book_name': 'sample', 'pages': 1}))
@unittest.skip("DOC to JSON test is currently disabled (e.g., due to missing support or failing test).")
def test_docs_to_json(self):
self.assertEqual(ab.create_json_book("assets/sample.doc"), (output['docs'], {'book_name': 'sample', 'pages': 1}))

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Deepak Raj <[email protected]>
@codeperfectplus codeperfectplus merged commit 6a955ed into Py-Contributors:dev Dec 9, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from PyPDF2 to pypdf and clean up obsolete mobi_to_json test

2 participants