More py3 compat for plucker input

This commit is contained in:
Kovid Goyal 2021-06-04 05:09:39 +05:30
parent 69eac37671
commit eea1a02373
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -371,7 +371,7 @@ class Reader(FormatReader):
html += self.process_phtml(section_data.data, section_data.header.paragraph_offsets) html += self.process_phtml(section_data.data, section_data.header.paragraph_offsets)
elif section_header.type == DATATYPE_PHTML_COMPRESSED: elif section_header.type == DATATYPE_PHTML_COMPRESSED:
d = self.decompress_phtml(section_data.data) d = self.decompress_phtml(section_data.data)
html += self.process_phtml(d, section_data.header.paragraph_offsets).decode(self.get_text_uid_encoding(section_header.uid), 'replace') html += self.process_phtml(d, section_data.header.paragraph_offsets)
html += '</body></html>' html += '</body></html>'
htmlf.write(html.encode('utf-8')) htmlf.write(html.encode('utf-8'))
@ -476,7 +476,7 @@ class Reader(FormatReader):
from calibre.ebooks.compression.palmdoc import decompress_doc from calibre.ebooks.compression.palmdoc import decompress_doc
return decompress_doc(data) return decompress_doc(data)
def process_phtml(self, d, paragraph_offsets=[]): def process_phtml(self, d, paragraph_offsets=()):
html = u'<p id="p0">' html = u'<p id="p0">'
offset = 0 offset = 0
paragraph_open = True paragraph_open = True
@ -728,9 +728,3 @@ class Reader(FormatReader):
html += u'</p>' html += u'</p>'
return html return html
def get_text_uid_encoding(self, uid):
# Return the user sepcified input encoding,
# otherwise return the alternate encoding specified for the uid,
# otherwise retur the default encoding for the document.
return self.options.input_encoding if self.options.input_encoding else self.uid_text_secion_encoding.get(uid, self.default_encoding)