From c21a870b8e7beda3fb2972621aaaa42505bb7aae Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 22 Jan 2023 11:31:47 +0100 Subject: [PATCH] Migrated pypdf2 to the now active developed pypdf --- cps/uploader.py | 18 ++++++++++++------ requirements.txt | 2 +- setup.cfg | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cps/uploader.py b/cps/uploader.py index 94f2aaa4..f93aef06 100644 --- a/cps/uploader.py +++ b/cps/uploader.py @@ -37,16 +37,22 @@ except (ImportError, RuntimeError) as e: use_generic_pdf_cover = True try: - from PyPDF2 import PdfReader + from PyPDF import PdfReader use_pdf_meta = True except ImportError as ex: - log.debug('PyPDF2 is recommended for best performance in metadata extracting from pdf files: %s', ex) + log.debug('PyPDF is recommended for best performance in metadata extracting from pdf files: %s', ex) try: - from PyPDF3 import PdfFileReader as PdfReader + from PyPDF2 import PdfReader use_pdf_meta = True - except ImportError as e: - log.debug('Cannot import PyPDF3/PyPDF2, extracting pdf metadata will not work: %s / %s', e) - use_pdf_meta = False + except ImportError as ex: + log.debug('PyPDF is recommended for best performance in metadata extracting from pdf files: %s', ex) + log.debug('PyPdf2 is also possible for metadata extracting from pdf files, but not recommended anymore') + try: + from PyPDF3 import PdfFileReader as PdfReader + use_pdf_meta = True + except ImportError as e: + log.debug('Cannot import PyPDF3/PyPDF2, extracting pdf metadata will not work: %s / %s', e) + use_pdf_meta = False try: from . import epub diff --git a/requirements.txt b/requirements.txt index decfee4c..ba37df7e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ Flask-Principal>=0.3.2,<0.5.1 backports_abc>=0.4 Flask>=1.0.2,<2.2.0 iso-639>=0.4.5,<0.5.0 -PyPDF2>=1.28,<3.1.0 +PyPDF>=3.0.0,<3.3.0 pytz>=2016.10 requests>=2.11.1,<2.28.0 SQLAlchemy>=1.3.0,<1.5.0 diff --git a/setup.cfg b/setup.cfg index 20e54749..8f5d1920 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,6 +23,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Operating System :: OS Independent keywords = calibre @@ -46,7 +47,7 @@ install_requires = backports_abc>=0.4 Flask>=1.0.2,<2.2.0 iso-639>=0.4.5,<0.5.0 - PyPDF2>=1.28,<3.1.0 + PyPDF>=3.0.0,<3.3.0 pytz>=2016.10 requests>=2.11.1,<2.28.0 SQLAlchemy>=1.3.0,<1.5.0