mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-02 18:43:33 +02:00
Sorted out mime initialization.
Every mime related function in main __init__.py has a flag check for the check if initialization has already done. This is nonsense, since it should be done implicitly early on the converter is starting. This commit straight the things out, and initialization is done in cli module. Also, function guess_type was removed, since it's just a proxy for mimetypes.guess_type function.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import mimetypes
|
||||
import sys, os, re
|
||||
from xml.sax.saxutils import escape
|
||||
from string import Formatter
|
||||
@@ -5,7 +6,7 @@ import pkg_resources
|
||||
import urllib.parse
|
||||
|
||||
from ebook_converter import constants as const
|
||||
from ebook_converter import guess_type, strftime
|
||||
from ebook_converter import strftime
|
||||
from ebook_converter.constants_old import iswindows
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.ebooks.oeb.base import XPath, xml2text, urlnormalize
|
||||
@@ -124,7 +125,8 @@ class Jacket(Base):
|
||||
alt_comments=comments, rescale_fonts=True)
|
||||
id, href = self.oeb.manifest.generate('calibre_jacket', 'jacket.xhtml')
|
||||
|
||||
jacket = self.oeb.manifest.add(id, href, guess_type(href)[0], data=root)
|
||||
jacket = self.oeb.manifest.add(id, href, mimetypes.guess_type(href)[0],
|
||||
data=root)
|
||||
self.oeb.spine.insert(0, jacket, True)
|
||||
self.oeb.inserted_metadata_jacket = jacket
|
||||
for img, path in referenced_images(root):
|
||||
@@ -132,7 +134,9 @@ class Jacket(Base):
|
||||
ext = path.rpartition('.')[-1].lower()
|
||||
item_id, href = self.oeb.manifest.generate('jacket_image', 'jacket_img.'+ext)
|
||||
with open(path, 'rb') as f:
|
||||
item = self.oeb.manifest.add(item_id, href, guess_type(href)[0], data=f.read())
|
||||
item = self.oeb.manifest.add(
|
||||
item_id, href, mimetypes.guess_type(href)[0],
|
||||
data=f.read())
|
||||
item.unload_data_from_memory()
|
||||
img.set('src', jacket.relhref(item.href))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user