Add an "all" keyword to export all known libraries

This commit is contained in:
Kovid Goyal 2018-07-11 07:12:38 +05:30
parent 525f74d8c0
commit 7c53c1b029
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 2 deletions

View File

@ -97,7 +97,8 @@ Everything after the -- is passed to the script.
help=_('Export all calibre data (books/settings/plugins). Normally, you will'
' be asked for the export dir and the libraries to export. You can also specify them'
' as command line arguments to skip the questions.'
' Use absolute paths for the export directory and libraries.'))
' Use absolute paths for the export directory and libraries.'
' The special keyword "all" can be used to export all libraries.'))
parser.add_option('--import-calibre-data', default=False, action='store_true',
help=_('Import previously exported calibre data'))
parser.add_option('-s', '--shutdown-running-calibre', default=False,

View File

@ -391,7 +391,10 @@ def run_exporter(export_dir=None, args=None):
raise SystemExit('You must specify the export dir and libraries to export')
export_dir = args[0]
all_libraries = {os.path.normcase(os.path.abspath(path)):lus for path, lus in all_known_libraries().iteritems()}
libraries = {os.path.normcase(os.path.abspath(os.path.expanduser(path))) for path in args[1:]}
if 'all' in args[1:]:
libraries = set(all_libraries)
else:
libraries = {os.path.normcase(os.path.abspath(os.path.expanduser(path))) for path in args[1:]}
if libraries - set(all_libraries):
raise SystemExit('Unknown library: ' + tuple(libraries - all_libraries)[0])
libraries = {p: all_libraries[p] for p in libraries}