From db6aa22eaef9b564e7809f4ccc711115e1cd15da Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 23 May 2019 02:00:47 -0700 Subject: [PATCH] Progress bar: unit types --- src/ocrmypdf/api.py | 2 +- src/ocrmypdf/optimize.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ocrmypdf/api.py b/src/ocrmypdf/api.py index 2d6ccecf..2344970e 100644 --- a/src/ocrmypdf/api.py +++ b/src/ocrmypdf/api.py @@ -15,7 +15,6 @@ # You should have received a copy of the GNU General Public License # along with OCRmyPDF. If not, see . -import argparse import logging import sys from pathlib import Path @@ -176,6 +175,7 @@ def ocrmypdf( # pylint: disable=unused-argument user_words=None, user_patterns=None, keep_temporary_files=None, + progress_bar=None, ): options = create_options(**locals()) check_options(options) diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py index fc1484f7..21351291 100644 --- a/src/ocrmypdf/optimize.py +++ b/src/ocrmypdf/optimize.py @@ -267,7 +267,10 @@ def _produce_jbig2_images(jbig2_groups, root, log, options): with concurrent.futures.ThreadPoolExecutor(max_workers=options.jobs) as executor: futures = jbig2_futures(executor, root, jbig2_groups) with tqdm( - total=len(jbig2_groups), desc="JBIG2", disable=not options.progress_bar + total=len(jbig2_groups), + desc="JBIG2", + unit='item', + disable=not options.progress_bar, ) as pbar: for future in concurrent.futures.as_completed(futures): proc = future.result() @@ -314,7 +317,9 @@ def convert_to_jbig2(pike, jbig2_groups, root, log, options): def transcode_jpegs(pike, jpegs, root, log, options): - for xref in tqdm(jpegs, desc="JPEGs", disable=not options.progress_bar): + for xref in tqdm( + jpegs, desc="JPEGs", unit='image', disable=not options.progress_bar + ): in_jpg = Path(jpg_name(root, xref)) opt_jpg = in_jpg.with_suffix('.opt.jpg') @@ -356,7 +361,10 @@ def transcode_pngs(pike, images, image_name_fn, root, log, options): ) ) with tqdm( - desc="PNGs", total=len(futures), disable=not options.progress_bar + desc="PNGs", + total=len(futures), + unit='image', + disable=not options.progress_bar, ) as pbar: for _future in concurrent.futures.as_completed(futures): pbar.update()