Pretty print the metadata in txtz files

This commit is contained in:
Kovid Goyal 2021-07-05 11:38:14 +05:30
parent e9ea68aee2
commit 50d2b10315
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -127,9 +127,8 @@ class TXTZOutput(TXTOutput):
file_type = 'txtz'
def convert(self, oeb_book, output_path, input_plugin, opts, log):
from calibre.ebooks.oeb.base import OEB_IMAGES
from calibre.ebooks.oeb.base import OEB_IMAGES, xml2str
from calibre.utils.zipfile import ZipFile
from lxml import etree
with TemporaryDirectory('_txtz_output') as tdir:
# TXT
@ -159,7 +158,7 @@ class TXTZOutput(TXTOutput):
# Metadata
with open(os.path.join(tdir, 'metadata.opf'), 'wb') as mdataf:
mdataf.write(etree.tostring(oeb_book.metadata.to_opf1()))
mdataf.write(xml2str(oeb_book.metadata.to_opf1(), pretty_print=True))
txtz = ZipFile(output_path, 'w')
txtz.add_dir(tdir)