mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-21 13:41:30 +02:00
Cleanup get_path usage in favor of pkg_resources.
This commit is contained in:
@@ -10,6 +10,7 @@ import re
|
||||
from collections import Counter, OrderedDict
|
||||
from functools import partial
|
||||
from operator import itemgetter
|
||||
import pkg_resources
|
||||
|
||||
from lxml import etree
|
||||
from lxml.builder import ElementMaker
|
||||
@@ -690,7 +691,10 @@ def commit_nav_toc(container, toc, lang=None, landmarks=None, previous_nav=None)
|
||||
if previous_nav is not None:
|
||||
root = previous_nav[1]
|
||||
else:
|
||||
root = container.parse_xhtml(P('templates/new_nav.html', data=True).decode('utf-8'))
|
||||
with open(pkg_resources.
|
||||
resource_filename('ebook_converter',
|
||||
'data/new_nav.html')) as fobj:
|
||||
root = container.parse_xhtml(fobj.read())
|
||||
container.replace(tocname, root)
|
||||
else:
|
||||
root = container.parsed(tocname)
|
||||
|
||||
@@ -9,13 +9,13 @@ __docformat__ = 'restructuredtext en'
|
||||
import sys, os, re
|
||||
from xml.sax.saxutils import escape
|
||||
from string import Formatter
|
||||
import pkg_resources
|
||||
|
||||
from ebook_converter import guess_type, strftime
|
||||
from ebook_converter.constants import iswindows
|
||||
from ebook_converter.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag, urlnormalize
|
||||
from ebook_converter.library.comments import comments_to_html, markdown
|
||||
from ebook_converter.utils.date import is_date_undefined, as_local_time
|
||||
from ebook_converter.utils.icu import sort_key
|
||||
from ebook_converter.ebooks.chardet import strip_encoding_declarations
|
||||
from ebook_converter.ebooks.metadata import fmt_sidx, rating_to_stars
|
||||
from ebook_converter.polyglot.builtins import unicode_type, map
|
||||
@@ -196,7 +196,7 @@ class Tags(unicode_type):
|
||||
def __new__(self, tags, output_profile):
|
||||
tags = [escape(x) for x in tags or ()]
|
||||
t = unicode_type.__new__(self, ', '.join(tags))
|
||||
t.alphabetical = ', '.join(sorted(tags, key=sort_key))
|
||||
t.alphabetical = ', '.join(sorted(tags))
|
||||
t.tags_list = tags
|
||||
return t
|
||||
|
||||
@@ -232,8 +232,14 @@ def postprocess_jacket(root, output_profile, has_data):
|
||||
def render_jacket(mi, output_profile,
|
||||
alt_title=_('Unknown'), alt_tags=[], alt_comments='',
|
||||
alt_publisher='', rescale_fonts=False, alt_authors=None):
|
||||
css = P('jacket/stylesheet.css', data=True).decode('utf-8')
|
||||
template = P('jacket/template.xhtml', data=True).decode('utf-8')
|
||||
with open(pkg_resources.resource_filename('ebook_converter',
|
||||
'data/jacket/stylesheet.css'),
|
||||
'rb') as fobj:
|
||||
css = fobj.read().decode()
|
||||
with open(pkg_resources.resource_filename('ebook_converter',
|
||||
'data/jacket/template.xhtml'),
|
||||
'rb') as fobj:
|
||||
template = fobj.read().decode()
|
||||
|
||||
template = re.sub(r'<!--.*?-->', '', template, flags=re.DOTALL)
|
||||
css = re.sub(r'/\*.*?\*/', '', css, flags=re.DOTALL)
|
||||
|
||||
Reference in New Issue
Block a user