mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-13 21:25:54 +01:00
Replace Calibre path resolve system for some of the modules.
In Calibre there is a module, which registers two functions in global scope, one for filepath and one for images path. It relies on additional three variables, registered during application startup. I found it overcomplicated, and couple of the resource paths has been calculated using pkg_resource module.
This commit is contained in:
@@ -3,6 +3,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, glob, re, textwrap
|
||||
import pkg_resources
|
||||
|
||||
from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
|
||||
from ebook_converter.polyglot.builtins import iteritems, filter, getcwd, as_bytes
|
||||
@@ -282,7 +283,9 @@ class RTFInput(InputFormatPlugin):
|
||||
|
||||
self.log('Converting XML to HTML...')
|
||||
inline_class = InlineClass(self.log)
|
||||
styledoc = safe_xml_fromstring(P('templates/rtf.xsl', data=True), recover=False)
|
||||
with open(pkg_resources.resource_filename('ebook_converter',
|
||||
'data/rtf.xsl')) as fobj:
|
||||
styledoc = safe_xml_fromstring(fobj.read())
|
||||
extensions = {('calibre', 'inline-class') : inline_class}
|
||||
transform = etree.XSLT(styledoc, extensions=extensions)
|
||||
result = transform(doc)
|
||||
|
||||
Reference in New Issue
Block a user