mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-18 20:23:34 +02: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:
@@ -9,6 +9,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||
|
||||
import os, re, logging, copy, unicodedata, numbers
|
||||
import pkg_resources
|
||||
from operator import itemgetter
|
||||
from weakref import WeakKeyDictionary
|
||||
from xml.dom import SyntaxErr as CSSSyntaxError
|
||||
@@ -32,7 +33,8 @@ _html_css_stylesheet = None
|
||||
def html_css_stylesheet():
|
||||
global _html_css_stylesheet
|
||||
if _html_css_stylesheet is None:
|
||||
with open(P('templates/html.css'), 'rb') as f:
|
||||
with open(pkg_resources.resource_filename('ebook_converter',
|
||||
'data/html.css'), 'rb') as f:
|
||||
html_css = f.read().decode('utf-8')
|
||||
_html_css_stylesheet = parseString(html_css, validate=False)
|
||||
return _html_css_stylesheet
|
||||
|
||||
Reference in New Issue
Block a user