From eaa387a9d625c3391ed86f09728d80b4f76b479e Mon Sep 17 00:00:00 2001 From: blue Date: Tue, 28 Oct 2014 16:45:22 +0000 Subject: [PATCH 1/2] Add basic support for converting more >1 file --- kcc/comic2ebook.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 94d50e7..2595e83 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -57,10 +57,13 @@ def main(argv=None): parser = makeParser() options, args = parser.parse_args(argv) checkOptions() - if len(args) != 1: + if len(args) < 1: parser.print_help() return - outputPath = makeBook(args[0]) + for source in args: + if len(args) > 1: + print('\nWorking on {}...'.format(source)) + outputPath = makeBook(source) return outputPath @@ -1254,4 +1257,4 @@ def makeMOBI(work, qtGUI=None): makeMOBIWorkerPool.apply_async(func=makeMOBIWorker, args=(i, ), callback=makeMOBIWorkerTick) makeMOBIWorkerPool.close() makeMOBIWorkerPool.join() - return makeMOBIWorkerOutput \ No newline at end of file + return makeMOBIWorkerOutput From ac794eff859ad5038a526fbda168313bc3cd2b6c Mon Sep 17 00:00:00 2001 From: blue Date: Tue, 28 Oct 2014 18:34:14 +0000 Subject: [PATCH 2/2] Use glob to resolve file globs For systems where the shell doesn't do glob expansion, eg Windows. --- kcc/comic2ebook.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 2595e83..5922be9 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -25,6 +25,7 @@ __docformat__ = 'restructuredtext en' import os import sys +from glob import glob from json import loads from urllib.request import Request, urlopen from re import split, sub, compile @@ -57,11 +58,15 @@ def main(argv=None): parser = makeParser() options, args = parser.parse_args(argv) checkOptions() - if len(args) < 1: + if len(args) == 0: parser.print_help() return - for source in args: - if len(args) > 1: + sources = [source for arg in args for source in glob(arg)] + if len(sources) == 0: + print('No matching files found.') + return + for source in sources: + if len(sources) > 1: print('\nWorking on {}...'.format(source)) outputPath = makeBook(source) return outputPath