Drop support for Python 3.5
This commit is contained in:
@@ -193,12 +193,6 @@ def repair_and_parse_pdf(
|
||||
)
|
||||
raise InputFileError()
|
||||
|
||||
if len(pdfinfo.pages) > 2000 and sys.version_info[0:2] <= (3, 5):
|
||||
log.warning(
|
||||
"Performance regressions are known occur with Python 3.5 for "
|
||||
"high page count files. Python 3.6 or newer is recommended."
|
||||
)
|
||||
|
||||
if pdfinfo.has_acroform:
|
||||
if options.redo_ocr:
|
||||
log.error(
|
||||
|
||||
@@ -23,7 +23,7 @@ import re
|
||||
from PIL import Image
|
||||
from . import get_version
|
||||
from ..exceptions import SubprocessOutputError
|
||||
from ..helpers import fspath
|
||||
from os import fspath
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
|
||||
@@ -19,7 +19,7 @@ from subprocess import CalledProcessError, STDOUT, PIPE, run
|
||||
from functools import lru_cache
|
||||
|
||||
from . import get_version
|
||||
from ..helpers import fspath
|
||||
from os import fspath
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
|
||||
@@ -23,9 +23,10 @@ from collections import namedtuple
|
||||
from textwrap import dedent
|
||||
from subprocess import CalledProcessError, TimeoutExpired, check_output, STDOUT, run, PIPE
|
||||
from contextlib import suppress
|
||||
from os import fspath
|
||||
|
||||
from ..exceptions import MissingDependencyError, TesseractConfigError
|
||||
from ..helpers import page_number, fspath
|
||||
from ..helpers import page_number
|
||||
from . import get_version
|
||||
|
||||
OrientationConfidence = namedtuple(
|
||||
|
||||
+5
-45
@@ -29,8 +29,8 @@ def re_symlink(input_file, soft_link_name, log=None):
|
||||
"""
|
||||
Helper function: relinks soft symbolic link if necessary
|
||||
"""
|
||||
input_file = fspath(input_file) # For Py3.5
|
||||
soft_link_name = fspath(soft_link_name)
|
||||
input_file = os.fspath(input_file)
|
||||
soft_link_name = os.fspath(soft_link_name)
|
||||
if log is None:
|
||||
prdebug = partial(print, file=sys.stderr)
|
||||
else:
|
||||
@@ -72,7 +72,7 @@ def is_iterable_notstr(thing):
|
||||
|
||||
def page_number(input_file):
|
||||
"""Get one-based page number implied by filename (000002.pdf -> 2)"""
|
||||
return int(os.path.basename(fspath(input_file))[0:6])
|
||||
return int(os.path.basename(os.fspath(input_file))[0:6])
|
||||
|
||||
|
||||
def available_cpu_count():
|
||||
@@ -103,19 +103,12 @@ def is_file_writable(test_file):
|
||||
p = Path(test_file)
|
||||
|
||||
if p.is_symlink():
|
||||
# Python 3.5 does not accept parameters for Path.resolve() and behaves
|
||||
# as if strict=True (throws an exception on failure). Python 3.6
|
||||
# defaults to strict=False. This implements strict=False like behavior
|
||||
# for Python 3.5.
|
||||
if sys.version_info[0:2] <= (3, 5):
|
||||
p = Path(os.path.realpath(fspath(p)))
|
||||
else:
|
||||
p = p.resolve(strict=False)
|
||||
p = p.resolve(strict=False)
|
||||
|
||||
# p.is_file() throws an exception in some cases
|
||||
if p.exists() and p.is_file():
|
||||
return os.access(
|
||||
fspath(p), os.W_OK,
|
||||
os.fspath(p), os.W_OK,
|
||||
effective_ids=(os.access in os.supports_effective_ids))
|
||||
else:
|
||||
try:
|
||||
@@ -129,39 +122,6 @@ def is_file_writable(test_file):
|
||||
return True
|
||||
|
||||
|
||||
if sys.version_info[0:2] <= (3, 5):
|
||||
def fspath(path):
|
||||
"""https://www.python.org/dev/peps/pep-0519/#os"""
|
||||
import pathlib
|
||||
if isinstance(path, (str, bytes)):
|
||||
return path
|
||||
|
||||
# Work from the object's type to match method resolution of other magic
|
||||
# methods.
|
||||
path_type = type(path)
|
||||
try:
|
||||
path = path_type.__fspath__(path)
|
||||
except AttributeError:
|
||||
# Added for Python 3.5 support.
|
||||
if isinstance(path, pathlib.Path):
|
||||
return str(path)
|
||||
elif hasattr(path_type, '__fspath__'):
|
||||
raise
|
||||
else:
|
||||
if isinstance(path, (str, bytes)):
|
||||
return path
|
||||
else:
|
||||
raise TypeError("expected __fspath__() to return str or bytes, "
|
||||
"not " + type(path).__name__)
|
||||
|
||||
raise TypeError(
|
||||
"expected str, bytes, pathlib.Path or os.PathLike object, not "
|
||||
+ path_type.__name__)
|
||||
|
||||
else:
|
||||
fspath = os.fspath
|
||||
|
||||
|
||||
def flatten_groups(groups):
|
||||
for obj in groups:
|
||||
if is_iterable_notstr(obj):
|
||||
|
||||
@@ -33,7 +33,7 @@ import sys
|
||||
import warnings
|
||||
|
||||
from .lib._leptonica import ffi
|
||||
from .helpers import fspath
|
||||
from os import fspath
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import concurrent.futures
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
import sys
|
||||
from os import fspath
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@@ -27,7 +28,7 @@ import pikepdf
|
||||
|
||||
from ._jobcontext import JobContext
|
||||
from . import leptonica
|
||||
from .helpers import re_symlink, fspath
|
||||
from .helpers import re_symlink
|
||||
from .exec import pngquant, jbig2enc
|
||||
|
||||
DEFAULT_JPEG_QUALITY = 75
|
||||
|
||||
@@ -20,6 +20,7 @@ from collections import namedtuple
|
||||
from decimal import Decimal
|
||||
from enum import Enum
|
||||
from math import hypot, isclose
|
||||
from os import fspath
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock
|
||||
from warnings import warn
|
||||
@@ -32,7 +33,6 @@ from . import ghosttext
|
||||
from .layout import get_page_analysis, get_text_boxes
|
||||
|
||||
from ..exceptions import EncryptedPdfError
|
||||
from ..helpers import fspath
|
||||
|
||||
|
||||
Colorspace = Enum('Colorspace',
|
||||
|
||||
Reference in New Issue
Block a user