Fix several pylint errors and warnings

This commit is contained in:
James R. Barlow
2018-06-23 00:54:22 -07:00
parent 94150f414a
commit 2530d1791b
6 changed files with 13 additions and 8 deletions
+1
View File
@@ -588,6 +588,7 @@ def do_ruffus_exception(ruffus_five_tuple, options, log):
exit_code = None
task_name, job_name, exc_name, exc_value, exc_stack = ruffus_five_tuple
task_name = task_name # unused
job_name = job_name # unused
if exc_name == 'builtins.SystemExit':
match = re.search(r"\.(.+?)\)", exc_value)
+5 -4
View File
@@ -169,7 +169,7 @@ def extract_images(pike, root, log, options):
len(jbig2_groups), len(jpegs), len(pngs), errors
))
return changed_xrefs, jbig2_groups, jpegs, pngs
return jbig2_groups, jpegs, pngs
def convert_to_jbig2(pike, jbig2_groups, root, log, options):
@@ -208,7 +208,7 @@ def convert_to_jbig2(pike, jbig2_groups, root, log, options):
jbig2_globals = pikepdf.Stream(pike, jbig2_globals_data)
for n, xref_ext in enumerate(xref_exts):
xref, ext = xref_ext
xref, _ = xref_ext
jbig2_im_file = root / (prefix + '.{:04d}'.format(n))
jbig2_im_data = jbig2_im_file.read_bytes()
im_obj = pike._get_object_id(xref, 0)
@@ -233,6 +233,7 @@ def transcode_jpegs(pike, jpegs, root, log, options):
im.save(fspath(opt_jpg),
optimize=True,
quality=JPEG_QUALITY)
# pylint: disable=E1101
if opt_jpg.stat().st_size > in_jpg.stat().st_size:
log.debug("xref {}, jpeg, made larger - skip".format(xref))
continue
@@ -322,8 +323,8 @@ def optimize(
pike = pikepdf.Pdf.open(input_file)
root = Path(output_file).parent / 'images'
root.mkdir(exist_ok=True)
changed_xrefs, jbig2_groups, jpegs, pngs = extract_images(
root.mkdir(exist_ok=True) # pylint: disable=E1101
jbig2_groups, jpegs, pngs = extract_images(
pike, root, log, options)
convert_to_jbig2(pike, jbig2_groups, root, log, options)
+1 -1
View File
@@ -295,7 +295,7 @@ class ImageInfo:
self._bpc = int(pim.bits_per_component)
try:
self._enc = FRIENDLY_ENCODING.get(pim.filters[0], 'image')
except IndexError as e:
except IndexError:
self._enc = '?'
try:
+1 -1
View File
@@ -309,7 +309,7 @@ def marker_pages(
# file a symlink back to the source.
for n in range(npages):
page = Path(work_folder) / '{0:06d}.marker.pdf'.format(n + 1)
page.symlink_to(input_file)
page.symlink_to(input_file) # pylint: disable=E1101
def split_page(
+4 -1
View File
@@ -26,6 +26,9 @@ from pathlib import Path
from subprocess import Popen, PIPE
# pylint: disable=E1101
# pytest.helpers is dynamic so it confuses pylint
if sys.version_info.major < 3:
print("Requires Python 3.4+")
sys.exit(1)
@@ -81,7 +84,7 @@ def spoof(tmpdir_factory, **kwargs):
env['_OCRMYPDF_SAVE_PATH'] = env['PATH']
env['PATH'] = str(tmpdir) + ":" + env['PATH']
return env
+1 -1
View File
@@ -34,7 +34,7 @@ import sys
@pytest.fixture
def blank_hocr(tmpdir):
filename = Path(str(tmpdir)) / "blank.hocr"
filename.write_text(HOCR_TEMPLATE)
filename.write_text(HOCR_TEMPLATE) # pylint: disable=E1101
return filename