From ae112c100979f15c95317c3f7356fb89b2ffd06d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Jan 2018 13:58:50 +0530 Subject: [PATCH] calibredb export: Add --progress option --- src/calibre/db/cli/cmd_export.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/calibre/db/cli/cmd_export.py b/src/calibre/db/cli/cmd_export.py index eabbf5de2f..e32295f2a4 100644 --- a/src/calibre/db/cli/cmd_export.py +++ b/src/calibre/db/cli/cmd_export.py @@ -69,6 +69,12 @@ an opf file). You can get id numbers from the search command. action='store_true', help=_('Export all books into a single directory') ) + parser.add_option( + '--progress', + default=False, + action='store_true', + help=_('Report progress') + ) c = config() for pref in ['asciiize', 'update_metadata', 'write_opf', 'save_cover']: opt = c.get_option(pref) @@ -138,6 +144,12 @@ def main(opts, args, dbctx): dest = os.path.abspath(os.path.expanduser(opts.to_dir)) dbproxy = DBProxy(dbctx) dest, opts, length = sanitize_args(dest, opts) + total = len(book_ids) for i, book_id in enumerate(book_ids): export(opts, dbctx, book_id, dest, dbproxy, length, i == 0) + if opts.progress: + num = i + 1 + print('\r {:.0%} [{}/{}]'.format(num / total, num, total), end=' '*20) + if opts.progress: + print() return 0