Fix a regression in calibre 5 that broke --explode-book and --implode-book in calibre-debug.exe

This commit is contained in:
Kovid Goyal 2021-03-21 20:00:00 +05:30
parent 9407f7b08f
commit 320c525cfe
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -126,7 +126,7 @@ def explode(ebook_file, output_dir):
return return
h = '_' if iswindows else '.' h = '_' if iswindows else '.'
with lopen(os.path.join(output_dir, h + '__explode_fmt__'), 'wb') as f: with lopen(os.path.join(output_dir, h + '__explode_fmt__'), 'wb') as f:
f.write(fmt) f.write(fmt.encode('utf-8'))
prints('Book extracted to', output_dir) prints('Book extracted to', output_dir)
prints('Make your changes and once you are done, use --implode-book to rebuild') prints('Make your changes and once you are done, use --implode-book to rebuild')
@ -141,7 +141,7 @@ def implode(output_dir, ebook_file):
efmt_path = os.path.join(output_dir, h + '__explode_fmt__') efmt_path = os.path.join(output_dir, h + '__explode_fmt__')
try: try:
with lopen(efmt_path, 'rb') as f: with lopen(efmt_path, 'rb') as f:
efmt = f.read() efmt = f.read().decode('utf-8')
except Exception: except Exception:
raise SystemExit('The folder %s does not seem to have been created by --explode-book' % output_dir) raise SystemExit('The folder %s does not seem to have been created by --explode-book' % output_dir)
if efmt != fmt: if efmt != fmt: