pylint removal
This commit is contained in:
@@ -26,9 +26,6 @@ if sys.version_info < (3, 6):
|
||||
sys.exit(1)
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from subprocess import STDOUT, check_output, CalledProcessError
|
||||
from collections.abc import Mapping
|
||||
import re
|
||||
|
||||
# pylint: disable=w0613
|
||||
|
||||
|
||||
+38
-38
@@ -15,59 +15,59 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import atexit
|
||||
import concurrent.futures
|
||||
import logging
|
||||
import logging.handlers
|
||||
import multiprocessing
|
||||
import threading
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
from collections import namedtuple
|
||||
from tempfile import mkdtemp
|
||||
from ._jobcontext import PDFContext, get_logger, cleanup_working_files
|
||||
from ._weave import OcrGrafter
|
||||
from ._pipeline import (
|
||||
triage,
|
||||
get_pdfinfo,
|
||||
validate_pdfinfo_options,
|
||||
is_ocr_required,
|
||||
rasterize_preview,
|
||||
get_orientation_correction,
|
||||
rasterize,
|
||||
preprocess_remove_background,
|
||||
preprocess_deskew,
|
||||
preprocess_clean,
|
||||
create_ocr_image,
|
||||
ocr_tesseract_hocr,
|
||||
should_visible_page_image_use_jpg,
|
||||
create_visible_page_jpg,
|
||||
create_pdf_page_from_image,
|
||||
render_hocr_page,
|
||||
ocr_tesseract_textonly_pdf,
|
||||
generate_postscript_stub,
|
||||
convert_to_pdfa,
|
||||
metadata_fixup,
|
||||
merge_sidecars,
|
||||
optimize_pdf,
|
||||
copy_final,
|
||||
)
|
||||
from .exceptions import ExitCode, ExitCodeException
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from . import VERSION
|
||||
from .helpers import available_cpu_count
|
||||
from ._jobcontext import PDFContext, cleanup_working_files, get_logger
|
||||
from ._pipeline import (
|
||||
convert_to_pdfa,
|
||||
copy_final,
|
||||
create_ocr_image,
|
||||
create_pdf_page_from_image,
|
||||
create_visible_page_jpg,
|
||||
generate_postscript_stub,
|
||||
get_orientation_correction,
|
||||
get_pdfinfo,
|
||||
is_ocr_required,
|
||||
merge_sidecars,
|
||||
metadata_fixup,
|
||||
ocr_tesseract_hocr,
|
||||
ocr_tesseract_textonly_pdf,
|
||||
optimize_pdf,
|
||||
preprocess_clean,
|
||||
preprocess_deskew,
|
||||
preprocess_remove_background,
|
||||
rasterize,
|
||||
rasterize_preview,
|
||||
render_hocr_page,
|
||||
should_visible_page_image_use_jpg,
|
||||
triage,
|
||||
validate_pdfinfo_options,
|
||||
)
|
||||
from ._validation import (
|
||||
check_options,
|
||||
check_dependency_versions,
|
||||
check_environ,
|
||||
check_options,
|
||||
check_requested_output_file,
|
||||
create_input_file,
|
||||
report_output_file_size,
|
||||
)
|
||||
from .pdfa import file_claims_pdfa
|
||||
from ._weave import OcrGrafter
|
||||
from .exceptions import ExitCode, ExitCodeException
|
||||
from .exec import qpdf
|
||||
|
||||
from tqdm import tqdm
|
||||
from .helpers import available_cpu_count
|
||||
from .pdfa import file_claims_pdfa
|
||||
|
||||
PageResult = namedtuple(
|
||||
'PageResult', 'pageno, pdf_page_from_image, ocr, text, orientation_correction'
|
||||
@@ -178,7 +178,7 @@ def log_listener(queue):
|
||||
logger = logging.getLogger(record.name)
|
||||
logger.handle(record)
|
||||
except Exception:
|
||||
import sys, traceback
|
||||
import traceback
|
||||
|
||||
print("Logging problem", file=sys.stderr)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
||||
+13
-15
@@ -19,7 +19,6 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import sys
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
@@ -27,17 +26,6 @@ from pathlib import Path
|
||||
import PIL
|
||||
|
||||
from ._unicodefun import verify_python3_env
|
||||
|
||||
from .exec import (
|
||||
ghostscript,
|
||||
jbig2enc,
|
||||
qpdf,
|
||||
tesseract,
|
||||
check_external_program,
|
||||
unpaper,
|
||||
pngquant,
|
||||
)
|
||||
from .helpers import is_file_writable, re_symlink
|
||||
from .exceptions import (
|
||||
BadArgsError,
|
||||
ExitCode,
|
||||
@@ -45,6 +33,16 @@ from .exceptions import (
|
||||
MissingDependencyError,
|
||||
OutputFileAccessError,
|
||||
)
|
||||
from .exec import (
|
||||
check_external_program,
|
||||
ghostscript,
|
||||
jbig2enc,
|
||||
pngquant,
|
||||
qpdf,
|
||||
tesseract,
|
||||
unpaper,
|
||||
)
|
||||
from .helpers import is_file_writable, re_symlink
|
||||
|
||||
# -------------
|
||||
# External dependencies
|
||||
@@ -331,7 +329,7 @@ def log_page_orientations(pdfinfo):
|
||||
if angle != 0:
|
||||
orientations.append('{0}{1}'.format(n + 1, direction.get(angle, '')))
|
||||
if orientations:
|
||||
log.info('Page orientations detected: ' + ' '.join(orientations))
|
||||
log.info('Page orientations detected: %s', ' '.join(orientations))
|
||||
|
||||
|
||||
def check_environ(options):
|
||||
@@ -384,7 +382,7 @@ def check_input_file(options, start_input_file):
|
||||
try:
|
||||
re_symlink(options.input_file, start_input_file, log)
|
||||
except FileNotFoundError:
|
||||
log.error("File not found - " + options.input_file)
|
||||
log.error("File not found - %s", options.input_file)
|
||||
raise InputFileError()
|
||||
|
||||
|
||||
@@ -402,7 +400,7 @@ def check_requested_output_file(options):
|
||||
raise BadArgsError()
|
||||
elif not is_file_writable(options.output_file):
|
||||
log.error(
|
||||
"Output file location (" + options.output_file + ") is not a writable file."
|
||||
"Output file location (%s) is not a writable file.", options.output_file
|
||||
)
|
||||
raise OutputFileAccessError()
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from contextlib import suppress
|
||||
from itertools import groupby
|
||||
from pathlib import Path
|
||||
import os
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
||||
import pikepdf
|
||||
|
||||
from .exec import tesseract
|
||||
|
||||
MAX_REPLACE_PAGES = int(os.environ.get('_OCRMYPDF_MAX_REPLACE_PAGES', 100))
|
||||
@@ -44,7 +45,7 @@ def _update_page_resources(*, page, font, font_key, procset):
|
||||
resources['/ProcSet'] = procset
|
||||
|
||||
|
||||
def strip_invisible_text(pdf, page, log):
|
||||
def strip_invisible_text(pdf, page):
|
||||
stream = []
|
||||
in_text_obj = False
|
||||
render_mode = 0
|
||||
@@ -151,7 +152,7 @@ def _weave_layers_graft(
|
||||
new_text_layer = pikepdf.Stream(pdf_base, pdf_text_contents)
|
||||
|
||||
if strip_old_text:
|
||||
strip_invisible_text(pdf_base, base_page, log)
|
||||
strip_invisible_text(pdf_base, base_page)
|
||||
|
||||
base_page.page_contents_add(new_text_layer, prepend=True)
|
||||
|
||||
@@ -205,7 +206,7 @@ class OcrGrafter:
|
||||
self.interim_count = 0
|
||||
|
||||
def graft_page(self, page_result):
|
||||
pageno, image, text, sidecar, autorotate_correction = page_result
|
||||
pageno, image, text, _sidecar, autorotate_correction = page_result
|
||||
if text and not self.font:
|
||||
self.font, self.font_key = _find_font(text, self.pdf_base)
|
||||
|
||||
@@ -262,7 +263,6 @@ class OcrGrafter:
|
||||
# lid on our memory usage for very large files. Attach the font to
|
||||
# page 1 even if page 1 doesn't use it, so we have a way to get it
|
||||
# back.
|
||||
# TODO refactor this to outside the loop
|
||||
page0 = self.pdf_base.pages[0]
|
||||
_update_page_resources(
|
||||
page=page0, font=self.font, font_key=self.font_key, procset=self.procset
|
||||
|
||||
@@ -172,6 +172,7 @@ class LTStateAwareChar(LTChar):
|
||||
- the Unicode mapping is known, and both have the same render mode
|
||||
- the Unicode mapping is unknown but both are part of the same font
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
both_unicode_mapped = isinstance(self._text, str) and isinstance(obj._text, str)
|
||||
try:
|
||||
if both_unicode_mapped:
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ def test_deskew(spoof_tesseract_noop, resources, outdir):
|
||||
)
|
||||
|
||||
pix = Pix.open(deskewed_png)
|
||||
skew_angle, skew_confidence = pix.find_skew()
|
||||
skew_angle, _skew_confidence = pix.find_skew()
|
||||
|
||||
print(skew_angle)
|
||||
assert -0.5 < skew_angle < 0.5, "Deskewing failed"
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
from os import fspath
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from ocrmypdf.__main__ import parser
|
||||
from ocrmypdf._validation import check_options
|
||||
from ocrmypdf.exceptions import ExitCode
|
||||
|
||||
Reference in New Issue
Block a user