Fix some recommendations from LGTM (#309)

* Fix unreachable code

This fixes an issue reported by LGTM.

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* Remove unused imports

This fixes several recommendations from LGTM.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil
2018-10-28 13:59:58 -07:00
committed by jbarlow83
parent f5807a2053
commit a873278c2a
7 changed files with 8 additions and 21 deletions
-1
View File
@@ -28,7 +28,6 @@ from setuptools import setup, find_packages # nopep8
from subprocess import STDOUT, check_output, CalledProcessError # nopep8
from collections.abc import Mapping # nopep8
import re # nopep8
import os # nopep8
missing_program = '''
+1 -1
View File
@@ -33,7 +33,7 @@ from .hocrtransform import HocrTransform
from .pdfinfo import PdfInfo, Colorspace
from .pdfa import generate_pdfa_ps, encode_pdf_date
from .helpers import re_symlink, is_iterable_notstr, page_number, flatten_groups
from .exec import ghostscript, tesseract, qpdf
from .exec import ghostscript, tesseract
from .exceptions import UnsupportedImageFormatError, \
DpiError, PriorOcrFoundError, InputFileError, EncryptedPdfError
from . import leptonica
+2 -5
View File
@@ -15,14 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import CalledProcessError, run, PIPE
from subprocess import run, PIPE
from functools import lru_cache
import sys
import os
import shutil
from . import get_version
from ..exceptions import ExitCode, MissingDependencyError
from ..exceptions import MissingDependencyError
@lru_cache(maxsize=1)
+2 -6
View File
@@ -15,15 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import CalledProcessError, run
from tempfile import TemporaryFile
from subprocess import run
from functools import lru_cache
import sys
import os
import shutil
from . import get_version
from ..exceptions import ExitCode, MissingDependencyError
from ..exceptions import MissingDependencyError
@lru_cache(maxsize=1)
-2
View File
@@ -18,8 +18,6 @@
from subprocess import CalledProcessError, STDOUT, PIPE, run
from functools import lru_cache
from ..exceptions import InputFileError, SubprocessOutputError, \
EncryptedPdfError
from . import get_version
+3 -4
View File
@@ -17,7 +17,7 @@
from pathlib import Path
import concurrent.futures
from collections import defaultdict, namedtuple
from collections import defaultdict
import logging
import sys
@@ -137,10 +137,9 @@ def extract_image_generic(*, pike, root, log, image, xref, options):
# generating a PNG from compressed data
pim.as_pil_image().save(png_name(root, xref))
return xref, '.png'
else:
return None
return True
return None
def extract_images(pike, root, log, options, extract_fn):
-2
View File
@@ -34,7 +34,6 @@ Ghostscript's handling of pdfmark.
from binascii import hexlify
from datetime import datetime
from pathlib import Path
from shutil import copyfile
from string import Template
import pkg_resources
import os
@@ -42,7 +41,6 @@ import os
from libxmp.utils import file_to_dict
from libxmp import consts
from ocrmypdf.helpers import fspath
ICC_PROFILE_RELPATH = 'data/sRGB.icc'