Progress bar: unit types

This commit is contained in:
James R. Barlow
2019-05-23 02:00:47 -07:00
parent 805aa776ad
commit db6aa22eae
2 changed files with 12 additions and 4 deletions

View File

@@ -15,7 +15,6 @@
# 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
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)

View File

@@ -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()