mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-16 06:33:31 +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:
@@ -7,11 +7,11 @@ This package contains logic to read and write LRF files.
|
||||
The LRF file format is documented at U{http://www.sven.de/librie/Librie/LrfFormat}.
|
||||
"""
|
||||
|
||||
from calibre.ebooks.lrf.pylrs.pylrs import Book as _Book
|
||||
from calibre.ebooks.lrf.pylrs.pylrs import TextBlock, Header, \
|
||||
from ebook_converter.ebooks.lrf.pylrs.pylrs import Book as _Book
|
||||
from ebook_converter.ebooks.lrf.pylrs.pylrs import TextBlock, Header, \
|
||||
TextStyle, BlockStyle
|
||||
from calibre.ebooks.lrf.fonts import FONT_FILE_MAP
|
||||
from calibre.ebooks import ConversionError
|
||||
from ebook_converter.ebooks.lrf.fonts import FONT_FILE_MAP
|
||||
from ebook_converter.ebooks import ConversionError
|
||||
|
||||
__docformat__ = "epytext"
|
||||
|
||||
@@ -38,7 +38,7 @@ class PRS500_PROFILE(object):
|
||||
|
||||
|
||||
def find_custom_fonts(options, logger):
|
||||
from calibre.utils.fonts.scanner import font_scanner
|
||||
from ebook_converter.utils.fonts.scanner import font_scanner
|
||||
fonts = {'serif' : None, 'sans' : None, 'mono' : None}
|
||||
|
||||
def family(cmd):
|
||||
|
||||
@@ -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>"
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
|
||||
""" elements.py -- replacements and helpers for ElementTree """
|
||||
|
||||
from polyglot.builtins import unicode_type, string_or_bytes
|
||||
from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes
|
||||
|
||||
|
||||
class ElementWriter(object):
|
||||
|
||||
@@ -12,7 +12,7 @@ import codecs
|
||||
import os
|
||||
|
||||
from .pylrfopt import tagListOptimizer
|
||||
from polyglot.builtins import iteritems, string_or_bytes, unicode_type
|
||||
from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, unicode_type
|
||||
|
||||
PYLRF_VERSION = "1.0"
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ from .pylrf import (LrfWriter, LrfObject, LrfTag, LrfToc,
|
||||
STREAM_COMPRESSED, LrfTagStream, LrfStreamBase, IMAGE_TYPE_ENCODING,
|
||||
BINDING_DIRECTION_ENCODING, LINE_TYPE_ENCODING, LrfFileStream,
|
||||
STREAM_FORCE_COMPRESSED)
|
||||
from calibre.utils.date import isoformat
|
||||
from ebook_converter.utils.date import isoformat
|
||||
|
||||
DEFAULT_SOURCE_ENCODING = "cp1252" # default is us-windows character set
|
||||
DEFAULT_GENREADING = "fs" # default is yes to both lrf and lrs
|
||||
|
||||
from calibre import __appname__, __version__
|
||||
from calibre import entity_to_unicode
|
||||
from polyglot.builtins import string_or_bytes, unicode_type, iteritems, native_string_type
|
||||
from ebook_converter import __appname__, __version__
|
||||
from ebook_converter import entity_to_unicode
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes, unicode_type, iteritems, native_string_type
|
||||
|
||||
|
||||
class LrsError(Exception):
|
||||
|
||||
Reference in New Issue
Block a user