1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-03-06 01:05:52 +01:00

Convert calibre modules to ebook_converter.

Here is the first batch of modules, which are needed for converting
several formats to LRF. Some of the logic has been change, more cleanups
will follow.
This commit is contained in:
2020-04-11 19:33:43 +02:00
parent 69d2e536c5
commit 0f9792df36
252 changed files with 1925 additions and 2344 deletions

View File

@@ -1,10 +0,0 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
"""
This package contains code to convert HTML ebooks to LRF ebooks.
"""
__docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"

View File

@@ -13,27 +13,27 @@ from functools import partial
from itertools import chain
from math import ceil, floor
from calibre import (
from ebook_converter import (
__appname__, entity_to_unicode, fit_image, force_unicode, preferred_encoding
)
from calibre.constants import filesystem_encoding
from calibre.devices.interface import DevicePlugin as Device
from calibre.ebooks import ConversionError
from calibre.ebooks.BeautifulSoup import (
from ebook_converter.constants import filesystem_encoding
from ebook_converter.devices.interface import DevicePlugin as Device
from ebook_converter.ebooks import ConversionError
from ebook_converter.ebooks.BeautifulSoup import (
BeautifulSoup, Comment, Declaration, NavigableString, ProcessingInstruction, Tag
)
from calibre.ebooks.chardet import xml_to_unicode
from calibre.ebooks.lrf import Book
from calibre.ebooks.lrf.html.color_map import lrs_color
from calibre.ebooks.lrf.html.table import Table
from calibre.ebooks.lrf.pylrs.pylrs import (
from ebook_converter.ebooks.chardet import xml_to_unicode
from ebook_converter.ebooks.lrf import Book
from ebook_converter.ebooks.lrf.html.color_map import lrs_color
from ebook_converter.ebooks.lrf.html.table import Table
from ebook_converter.ebooks.lrf.pylrs.pylrs import (
CR, BlockSpace, BookSetting, Canvas, CharButton, DropCaps, EmpLine, Image,
ImageBlock, ImageStream, Italic, JumpButton, LrsError, Paragraph, Plot,
RuledLine, Span, Sub, Sup, TextBlock
)
from calibre.ptempfile import PersistentTemporaryFile
from polyglot.builtins import getcwd, itervalues, string_or_bytes, unicode_type
from polyglot.urllib import unquote, urlparse
from ebook_converter.ptempfile import PersistentTemporaryFile
from ebook_converter.polyglot.builtins import getcwd, itervalues, string_or_bytes, unicode_type
from ebook_converter.polyglot.urllib import unquote, urlparse
"""
Code to convert HTML ebooks into LRF ebooks.
@@ -1911,7 +1911,7 @@ def try_opf(path, options, logger):
return
dirpath = os.path.dirname(os.path.abspath(opf))
from calibre.ebooks.metadata.opf2 import OPF as OPF2
from ebook_converter.ebooks.metadata.opf2 import OPF as OPF2
with open(opf, 'rb') as f:
opf = OPF2(f, dirpath)
try:

View File

@@ -4,11 +4,11 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import math, sys, re, numbers
from calibre.ebooks.lrf.fonts import get_font
from calibre.ebooks.lrf.pylrs.pylrs import TextBlock, Text, CR, Span, \
from ebook_converter.ebooks.lrf.fonts import get_font
from ebook_converter.ebooks.lrf.pylrs.pylrs import TextBlock, Text, CR, Span, \
CharButton, Plot, Paragraph, \
LrsTextTag
from polyglot.builtins import string_or_bytes, range, native_string_type
from ebook_converter.polyglot.builtins import string_or_bytes, range, native_string_type
def ceil(num):
@@ -16,7 +16,7 @@ def ceil(num):
def print_xml(elem):
from calibre.ebooks.lrf.pylrs.pylrs import ElementWriter
from ebook_converter.ebooks.lrf.pylrs.pylrs import ElementWriter
elem = elem.toElement(native_string_type('utf8'))
ew = ElementWriter(elem, sourceEncoding=native_string_type('utf8'))
ew.write(sys.stdout)