mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
calibredb export: Add --progress option
This commit is contained in:
parent
84d0fa8459
commit
ae112c1009
@ -69,6 +69,12 @@ an opf file). You can get id numbers from the search command.
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help=_('Export all books into a single directory')
|
help=_('Export all books into a single directory')
|
||||||
)
|
)
|
||||||
|
parser.add_option(
|
||||||
|
'--progress',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help=_('Report progress')
|
||||||
|
)
|
||||||
c = config()
|
c = config()
|
||||||
for pref in ['asciiize', 'update_metadata', 'write_opf', 'save_cover']:
|
for pref in ['asciiize', 'update_metadata', 'write_opf', 'save_cover']:
|
||||||
opt = c.get_option(pref)
|
opt = c.get_option(pref)
|
||||||
@ -138,6 +144,12 @@ def main(opts, args, dbctx):
|
|||||||
dest = os.path.abspath(os.path.expanduser(opts.to_dir))
|
dest = os.path.abspath(os.path.expanduser(opts.to_dir))
|
||||||
dbproxy = DBProxy(dbctx)
|
dbproxy = DBProxy(dbctx)
|
||||||
dest, opts, length = sanitize_args(dest, opts)
|
dest, opts, length = sanitize_args(dest, opts)
|
||||||
|
total = len(book_ids)
|
||||||
for i, book_id in enumerate(book_ids):
|
for i, book_id in enumerate(book_ids):
|
||||||
export(opts, dbctx, book_id, dest, dbproxy, length, i == 0)
|
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
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user