diff options
author | Patrick Nicholls <[email protected]> | 2017-04-24 21:48:53 +1200 |
---|---|---|
committer | Patrick Nicholls <[email protected]> | 2017-04-24 21:48:53 +1200 |
commit | 691a3d6955f4a18e264c1eaa56c9a563a65d2dc2 (patch) | |
tree | 3703f024dc9eed5233a991b32c4de7cb0df98380 /Other_Tools | |
parent | 6f0c36b67abb574136d973943ea7d54678bc52b5 (diff) |
Added --all flag to sys.args
Diffstat (limited to 'Other_Tools')
-rwxr-xr-x[-rw-r--r--] | Other_Tools/Kobo/obok.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Other_Tools/Kobo/obok.py b/Other_Tools/Kobo/obok.py index 37ee286..033c67a 100644..100755 --- a/Other_Tools/Kobo/obok.py +++ b/Other_Tools/Kobo/obok.py @@ -706,6 +706,7 @@ def cli_main(): epilog = u"Parsing of arguments failed." 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('--all', action='store_true', help="flag for converting all books on device") args = vars(parser.parse_args()) serials = [] devicedir = u"" @@ -714,20 +715,23 @@ def cli_main(): lib = KoboLibrary(serials, devicedir) - for i, book in enumerate(lib.books): - print u"{0}: {1}".format(i + 1, book.title) - print u"Or 'all'" - - choice = raw_input(u"Convert book number... ") - if choice == u'all': - books = list(lib.books) + if args['all']: + books = lib.books else: - try: - num = int(choice) - books = [lib.books[num - 1]] - except (ValueError, IndexError): - print u"Invalid choice. Exiting..." - exit() + for i, book in enumerate(lib.books): + print u"{0}: {1}".format(i + 1, book.title) + print u"Or 'all'" + + choice = raw_input(u"Convert book number... ") + 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] lib.close() |