From ac794eff859ad5038a526fbda168313bc3cd2b6c Mon Sep 17 00:00:00 2001 From: blue Date: Tue, 28 Oct 2014 18:34:14 +0000 Subject: [PATCH] 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