[FIX] P3: replace PyPDF by PyPDF2
PyPDF is unmaintained and abandoned (as noted on its home page http://pybrary.net/pyPdf/) and was never updated to Python 3. PyPDF2 is a fork which provides a mostly compatible API and is P3-compatible. Replace PyPDF by PyPDF2.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
import logging
|
||||
import pyPdf
|
||||
import PyPDF2
|
||||
import xml.dom.minidom
|
||||
import zipfile
|
||||
|
||||
@@ -110,7 +110,7 @@ class IrAttachment(models.Model):
|
||||
if bin_data.startswith('%PDF-'):
|
||||
f = StringIO(bin_data)
|
||||
try:
|
||||
pdf = pyPdf.PdfFileReader(f)
|
||||
pdf = PyPDF2.PdfFileReader(f, overwriteWarnings=False)
|
||||
for page in pdf.pages:
|
||||
buf += page.extractText()
|
||||
except Exception:
|
||||
|
||||
@@ -19,7 +19,7 @@ import re
|
||||
|
||||
from collections import namedtuple
|
||||
from contextlib import closing
|
||||
from pyPdf import PdfFileWriter, PdfFileReader
|
||||
from PyPDF2 import PdfFileWriter, PdfFileReader
|
||||
from distutils.version import LooseVersion
|
||||
from reportlab.graphics.barcode import createBarcodeDrawing
|
||||
|
||||
@@ -84,7 +84,7 @@ def _merge_pdf(documents):
|
||||
for document in documents:
|
||||
pdfreport = open(document, 'rb')
|
||||
streams.append(pdfreport)
|
||||
reader = PdfFileReader(pdfreport)
|
||||
reader = PdfFileReader(pdfreport, overwriteWarnings=False)
|
||||
for page in range(0, reader.getNumPages()):
|
||||
writer.addPage(reader.getPage(page))
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ psycopg2==2.6.2
|
||||
pydot==1.2.3
|
||||
pyldap==2.4.28
|
||||
pyparsing==2.1.10
|
||||
pyPdf==1.13
|
||||
PyPDF2==1.26.0
|
||||
pyserial==3.1.1
|
||||
python-dateutil==2.5.3
|
||||
python-openid==2.2.5
|
||||
|
||||
Reference in New Issue
Block a user