Added progress counter, #601

This commit is contained in:
Rhet Turnbull 2022-01-29 19:02:25 -08:00
parent 911bd30d28
commit 7ab500740b

View File

@ -1896,10 +1896,12 @@ def export(
else None
)
photo_num = 0
# send progress bar output to /dev/null if verbose to hide the progress bar
fp = open(os.devnull, "w") if verbose else None
with click.progressbar(photos, file=fp) as bar:
with click.progressbar(photos, show_pos=True, file=fp) as bar:
for p in bar:
photo_num += 1
export_results = export_photo(
photo=p,
dest=dest,
@ -1946,6 +1948,8 @@ def export(
export_preview=preview,
preview_suffix=preview_suffix,
preview_if_missing=preview_if_missing,
photo_num=photo_num,
num_photos=num_photos,
)
if post_function:
@ -2624,6 +2628,8 @@ def export_photo(
export_preview=False,
preview_suffix=None,
preview_if_missing=False,
photo_num=1,
num_photos=1,
):
"""Helper function for export that does the actual export
@ -2668,6 +2674,8 @@ def export_photo(
export_preview: export the preview image generated by Photos
preview_suffix: str, template to use as suffix for preview images
preview_if_missing: bool, export preview if original is missing
photo_num: int, which number photo in total of num_photos is being exported
num_photos: int, total number of photos that will be exported
Returns:
list of path(s) of exported photo or None if photo was missing
@ -2789,7 +2797,7 @@ def export_photo(
original_filename = str(original_filename)
verbose_(
f"Exporting {photo.original_filename} ({photo.filename}) as {original_filename}"
f"Exporting {photo.original_filename} ({photo.filename}) as {original_filename} ({photo_num}/{num_photos})"
)
results += export_photo_to_directory(