Fix raw_input() for importing calibre data via calibre-debug

This commit is contained in:
Kovid Goyal 2018-07-11 14:50:33 +05:30
parent 7c53c1b029
commit ed437c3e0d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -390,6 +390,10 @@ def run_exporter(export_dir=None, args=None):
if len(args) < 2:
raise SystemExit('You must specify the export dir and libraries to export')
export_dir = args[0]
if not os.path.exists(export_dir):
os.makedirs(export_dir)
if os.listdir(export_dir):
raise SystemExit('%s is not empty' % export_dir)
all_libraries = {os.path.normcase(os.path.abspath(path)):lus for path, lus in all_known_libraries().iteritems()}
if 'all' in args[1:]:
libraries = set(all_libraries)
@ -422,7 +426,7 @@ def run_exporter(export_dir=None, args=None):
def run_importer():
export_dir = raw_input('Enter path to folder containing previously exported data: ').decode(filesystem_encoding)
export_dir = raw_input('Enter path to folder containing previously exported data: ').decode(filesystem_encoding).rstrip('\r')
if not os.path.isdir(export_dir):
raise SystemExit('%s is not a folder' % export_dir)
try:
@ -430,7 +434,7 @@ def run_importer():
except ValueError as err:
raise SystemExit(err.message)
import_dir = raw_input('Enter path to an empty folder (all libraries will be created inside this folder): ').decode(filesystem_encoding)
import_dir = raw_input('Enter path to an empty folder (all libraries will be created inside this folder): ').decode(filesystem_encoding).rstrip('\r')
if not os.path.exists(import_dir):
os.makedirs(import_dir)
if not os.path.isdir(import_dir):