mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-02 18:43:33 +02: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,7 +7,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re, codecs
|
||||
from polyglot.builtins import unicode_type
|
||||
from ebook_converter.polyglot.builtins import unicode_type
|
||||
|
||||
_encoding_pats = (
|
||||
# XML declaration
|
||||
@@ -98,7 +98,7 @@ def find_declared_encoding(raw, limit=50*1024):
|
||||
|
||||
|
||||
def substitute_entites(raw):
|
||||
from calibre import xml_entity_to_unicode
|
||||
from ebook_converter import xml_entity_to_unicode
|
||||
return ENTITY_PATTERN.sub(xml_entity_to_unicode, raw)
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ def detect(*args, **kwargs):
|
||||
|
||||
|
||||
def force_encoding(raw, verbose, assume_utf8=False):
|
||||
from calibre.constants import preferred_encoding
|
||||
from ebook_converter.constants import preferred_encoding
|
||||
|
||||
try:
|
||||
chardet = detect(raw[:1024*50])
|
||||
|
||||
Reference in New Issue
Block a user