mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Avoid unnecessary QUrl round-tripping
This commit is contained in:
parent
4637e39350
commit
877810c134
@ -9,7 +9,7 @@ __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
|||||||
import os
|
import os
|
||||||
from urlparse import urldefrag
|
from urlparse import urldefrag
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from PyQt4.QtCore import Qt, QUrl
|
from PyQt4.QtCore import Qt
|
||||||
from PyQt4.QtCore import QByteArray
|
from PyQt4.QtCore import QByteArray
|
||||||
from PyQt4.QtCore import QBuffer
|
from PyQt4.QtCore import QBuffer
|
||||||
from PyQt4.QtCore import QIODevice
|
from PyQt4.QtCore import QIODevice
|
||||||
@ -17,7 +17,6 @@ from PyQt4.QtGui import QColor
|
|||||||
from PyQt4.QtGui import QImage
|
from PyQt4.QtGui import QImage
|
||||||
from PyQt4.QtGui import QPainter
|
from PyQt4.QtGui import QPainter
|
||||||
from PyQt4.QtSvg import QSvgRenderer
|
from PyQt4.QtSvg import QSvgRenderer
|
||||||
from calibre.constants import iswindows
|
|
||||||
from calibre.ebooks.oeb.base import XHTML, XLINK
|
from calibre.ebooks.oeb.base import XHTML, XLINK
|
||||||
from calibre.ebooks.oeb.base import SVG_MIME, PNG_MIME
|
from calibre.ebooks.oeb.base import SVG_MIME, PNG_MIME
|
||||||
from calibre.ebooks.oeb.base import xml2str, xpath
|
from calibre.ebooks.oeb.base import xml2str, xpath
|
||||||
@ -125,10 +124,7 @@ class SVGRasterizer(object):
|
|||||||
with PersistentTemporaryFile(suffix='.'+ext) as pt:
|
with PersistentTemporaryFile(suffix='.'+ext) as pt:
|
||||||
pt.write(data)
|
pt.write(data)
|
||||||
self.temp_files.append(pt.name)
|
self.temp_files.append(pt.name)
|
||||||
href = unicode(QUrl.fromLocalFile(pt.name).toString())[len('file://'):]
|
elem.attrib[XLINK('href')] = pt.name
|
||||||
if iswindows:
|
|
||||||
href = href[1:]
|
|
||||||
elem.attrib[XLINK('href')] = href
|
|
||||||
return svg
|
return svg
|
||||||
|
|
||||||
def stylizer(self, item):
|
def stylizer(self, item):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user