Added --all flag to sys.args
This commit is contained in:
parent
6f0c36b67a
commit
691a3d6955
|
@ -706,6 +706,7 @@ def cli_main():
|
||||||
epilog = u"Parsing of arguments failed."
|
epilog = u"Parsing of arguments failed."
|
||||||
parser = argparse.ArgumentParser(prog=sys.argv[0], description=description, epilog=epilog)
|
parser = argparse.ArgumentParser(prog=sys.argv[0], description=description, epilog=epilog)
|
||||||
parser.add_argument('--devicedir', default='/media/KOBOeReader', help="directory of connected Kobo device")
|
parser.add_argument('--devicedir', default='/media/KOBOeReader', help="directory of connected Kobo device")
|
||||||
|
parser.add_argument('--all', action='store_true', help="flag for converting all books on device")
|
||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
serials = []
|
serials = []
|
||||||
devicedir = u""
|
devicedir = u""
|
||||||
|
@ -714,20 +715,23 @@ def cli_main():
|
||||||
|
|
||||||
lib = KoboLibrary(serials, devicedir)
|
lib = KoboLibrary(serials, devicedir)
|
||||||
|
|
||||||
for i, book in enumerate(lib.books):
|
if args['all']:
|
||||||
print u"{0}: {1}".format(i + 1, book.title)
|
books = lib.books
|
||||||
print u"Or 'all'"
|
|
||||||
|
|
||||||
choice = raw_input(u"Convert book number... ")
|
|
||||||
if choice == u'all':
|
|
||||||
books = list(lib.books)
|
|
||||||
else:
|
else:
|
||||||
try:
|
for i, book in enumerate(lib.books):
|
||||||
num = int(choice)
|
print u"{0}: {1}".format(i + 1, book.title)
|
||||||
books = [lib.books[num - 1]]
|
print u"Or 'all'"
|
||||||
except (ValueError, IndexError):
|
|
||||||
print u"Invalid choice. Exiting..."
|
choice = raw_input(u"Convert book number... ")
|
||||||
exit()
|
if choice == u'all':
|
||||||
|
books = list(lib.books)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
num = int(choice)
|
||||||
|
books = [lib.books[num - 1]]
|
||||||
|
except (ValueError, IndexError):
|
||||||
|
print u"Invalid choice. Exiting..."
|
||||||
|
exit()
|
||||||
|
|
||||||
results = [decrypt_book(book, lib) for book in books]
|
results = [decrypt_book(book, lib) for book in books]
|
||||||
lib.close()
|
lib.close()
|
||||||
|
|
Loading…
Reference in New Issue