mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:22:45 +02:00
py3: Port use of no longer extant elements package
This commit is contained in:
parent
6987e86108
commit
a7f3fd798b
1 changed files with 8 additions and 16 deletions
|
|
@ -37,16 +37,11 @@
|
|||
# Plot, Image (outside of ImageBlock),
|
||||
# EmpLine, EmpDots
|
||||
|
||||
import os, re, codecs, operator
|
||||
import os, re, codecs, operator, io
|
||||
from xml.sax.saxutils import escape
|
||||
from datetime import date
|
||||
try:
|
||||
from elementtree.ElementTree import (Element, SubElement)
|
||||
Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import (Element, SubElement)
|
||||
from xml.etree.ElementTree import Element, SubElement, ElementTree
|
||||
|
||||
from elements import ElementWriter
|
||||
from pylrf import (LrfWriter, LrfObject, LrfTag, LrfToc,
|
||||
STREAM_COMPRESSED, LrfTagStream, LrfStreamBase, IMAGE_TYPE_ENCODING,
|
||||
BINDING_DIRECTION_ENCODING, LINE_TYPE_ENCODING, LrfFileStream,
|
||||
|
|
@ -624,12 +619,8 @@ def render(self, f, outputEncodingName='UTF-8'):
|
|||
# now, add some newlines to make it easier to look at
|
||||
|
||||
_formatXml(root)
|
||||
|
||||
writer = ElementWriter(root, header=True,
|
||||
sourceEncoding=self.sourceencoding,
|
||||
spaceBeforeClose=False,
|
||||
outputEncodingName=outputEncodingName)
|
||||
writer.write(f)
|
||||
tree = ElementTree(element=root)
|
||||
tree.write(f, encoding=outputEncodingName, xml_declaration=True)
|
||||
|
||||
|
||||
class BookInformation(Delegator):
|
||||
|
|
@ -679,9 +670,10 @@ def toLrf(self, lrfWriter):
|
|||
|
||||
# fix up the doc info to match the LRF format
|
||||
# NB: generates an encoding attribute, which lrs2lrf does not
|
||||
xmlInfo = ElementWriter(info, header=True, sourceEncoding=lrfWriter.getSourceEncoding(),
|
||||
spaceBeforeClose=False).toString()
|
||||
|
||||
tree = ElementTree(element=info)
|
||||
f = io.BytesIO()
|
||||
tree.write(f, encoding='utf-8', xml_declaration=True)
|
||||
xmlInfo = f.getvalue().decode('utf-8')
|
||||
xmlInfo = re.sub(r"<CThumbnail.*?>\n", "", xmlInfo)
|
||||
xmlInfo = xmlInfo.replace("SumPage>", "Page>")
|
||||
lrfWriter.docInfoXml = xmlInfo
|
||||
|
|
|
|||
Loading…
Reference in a new issue