Let holdit take many books.

This commit is contained in:
Ethan Dalool 2019-08-29 13:46:34 -07:00
parent 4d224e7d6a
commit f93309a37c

View file

@ -1051,13 +1051,19 @@ def covercomesfirst_argparse(args):
covercomesfirst(book) covercomesfirst(book)
def holdit_argparse(args): def holdit_argparse(args):
book = Epub.open(args.epub) epubs = [epub for pattern in args.epubs for epub in glob.glob(pattern)]
print(book.root_directory.absolute_path) books = []
for epub in epubs:
book = Epub.open(epub)
print(f'{epub} = {book.root_directory.absolute_path}')
books.append((epub, book))
input('Press Enter when ready.') input('Press Enter when ready.')
for (epub, book) in books:
# Saving re-writes the opf from memory, which might undo any manual changes. # Saving re-writes the opf from memory, which might undo any manual changes.
# So let's re-read it first. # So let's re-read it first.
book.read_opf(book.opf_filepath) book.read_opf(book.opf_filepath)
book.save(args.epub) book.save(epub)
def merge(input_filepaths, output_filename, do_headerfile=False): def merge(input_filepaths, output_filename, do_headerfile=False):
book = Epub.new() book = Epub.new()
@ -1148,7 +1154,7 @@ def main(argv):
p_covercomesfirst.set_defaults(func=covercomesfirst_argparse) p_covercomesfirst.set_defaults(func=covercomesfirst_argparse)
p_holdit = subparsers.add_parser('holdit') p_holdit = subparsers.add_parser('holdit')
p_holdit.add_argument('epub') p_holdit.add_argument('epubs', nargs='+', default=[])
p_holdit.set_defaults(func=holdit_argparse) p_holdit.set_defaults(func=holdit_argparse)
p_merge = subparsers.add_parser('merge') p_merge = subparsers.add_parser('merge')