diff --git a/.gitignore b/.gitignore
index bee8a64..aa260a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
__pycache__
+build/
+dist/
+sdist/
+*.egg-info/
diff --git a/README.rst b/README.rst
index 5fd4206..6c2e274 100644
--- a/README.rst
+++ b/README.rst
@@ -6,7 +6,7 @@ This is impudent ripoff of the bits from `Calibre project`_, and is aimed only
for converter thing.
My motivation is to have only converter for ebooks run from commandline,
-without all of those bells and whistles Calibre have, and with cleanest more
+without all of those bells and whistles Calibre has, and with cleanest more
*pythonic* approach.
diff --git a/ebook_converter/__init__.py b/ebook_converter/__init__.py
index 30d38f6..3664289 100644
--- a/ebook_converter/__init__.py
+++ b/ebook_converter/__init__.py
@@ -1,11 +1,10 @@
-from __future__ import unicode_literals, print_function
''' E-book management software'''
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
__docformat__ = 'restructuredtext en'
import sys, os, re, time, random, warnings
-from polyglot.builtins import codepoint_to_chr, unicode_type, range, hasenv, native_string_type
+from ebook_converter.polyglot.builtins import codepoint_to_chr, unicode_type, range, hasenv, native_string_type
from math import floor
from functools import partial
@@ -16,12 +15,12 @@ try:
except EnvironmentError:
os.chdir(os.path.expanduser('~'))
-from calibre.constants import (iswindows, isosx, islinux, isfrozen,
+from ebook_converter.constants import (iswindows, isosx, islinux, isfrozen,
isbsd, preferred_encoding, __appname__, __version__, __author__,
win32event, win32api, winerror, fcntl, ispy3,
filesystem_encoding, plugins, config_dir)
-from calibre.startup import winutil, winutilerror
-from calibre.utils.icu import safe_chr
+from ebook_converter.startup import winutil, winutilerror
+from ebook_converter.utils.icu import safe_chr
if False:
# Prevent pyflakes from complaining
@@ -163,7 +162,7 @@ def prints(*args, **kwargs):
for i, arg in enumerate(args):
if isinstance(arg, unicode_type):
if iswindows:
- from calibre.utils.terminal import Detect
+ from ebook_converter.utils.terminal import Detect
cs = Detect(file)
if cs.is_console:
cs.write_unicode_text(arg)
@@ -255,19 +254,19 @@ def extract(path, dir):
with open(path, 'rb') as f:
id_ = f.read(3)
if id_ == b'Rar':
- from calibre.utils.unrar import extract as rarextract
+ from ebook_converter.utils.unrar import extract as rarextract
extractor = rarextract
elif id_.startswith(b'PK'):
- from calibre.libunzip import extract as zipextract
+ from ebook_converter.libunzip import extract as zipextract
extractor = zipextract
if extractor is None:
# Fallback to file extension
ext = os.path.splitext(path)[1][1:].lower()
if ext in ['zip', 'cbz', 'epub', 'oebzip']:
- from calibre.libunzip import extract as zipextract
+ from ebook_converter.libunzip import extract as zipextract
extractor = zipextract
elif ext in ['cbr', 'rar']:
- from calibre.utils.unrar import extract as rarextract
+ from ebook_converter.utils.unrar import extract as rarextract
extractor = rarextract
if extractor is None:
raise Exception('Unknown archive type')
@@ -363,7 +362,7 @@ def is_mobile_ua(ua):
def random_user_agent(choose=None, allow_ie=True):
- from calibre.utils.random_ua import common_user_agents
+ from ebook_converter.utils.random_ua import common_user_agents
ua_list = common_user_agents()
ua_list = [x for x in ua_list if not is_mobile_ua(x)]
if not allow_ie:
@@ -380,7 +379,7 @@ def browser(honor_time=True, max_time=2, mobile_browser=False, user_agent=None,
:param max_time: Maximum time in seconds to wait during a refresh request
:param verify_ssl_certificates: If false SSL certificates errors are ignored
'''
- from calibre.utils.browser import Browser
+ from ebook_converter.utils.browser import Browser
opener = Browser(verify_ssl=verify_ssl_certificates)
opener.set_handle_refresh(handle_refresh, max_time=max_time, honor_time=honor_time)
opener.set_handle_robots(False)
@@ -560,7 +559,7 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
return check(bytes(bytearray((num,))).decode(encoding))
except UnicodeDecodeError:
return check(my_unichr(num))
- from calibre.ebooks.html_entities import html5_entities
+ from ebook_converter.ebooks.html_entities import html5_entities
try:
return check(html5_entities[ent])
except KeyError:
@@ -654,7 +653,7 @@ def human_readable(size, sep=' '):
def ipython(user_ns=None):
- from calibre.utils.ipython import ipython
+ from ebook_converter.utils.ipython import ipython
ipython(user_ns=user_ns)
diff --git a/ebook_converter/constants.py b/ebook_converter/constants.py
index 83b89fd..646f56d 100644
--- a/ebook_converter/constants.py
+++ b/ebook_converter/constants.py
@@ -1,8 +1,7 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2015, Kovid Goyal
-from __future__ import print_function, unicode_literals
-from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv, as_unicode, native_string_type
+from ebook_converter.polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv, as_unicode, native_string_type
import sys, locale, codecs, os, importlib, collections
__appname__ = 'calibre'
@@ -151,9 +150,9 @@ def cache_dir():
return ans
-plugins_loc = sys.extensions_location
-if ispy3:
- plugins_loc = os.path.join(plugins_loc, '3')
+# plugins_loc = sys.extensions_location
+# if ispy3:
+ # plugins_loc = os.path.join(plugins_loc, '3')
# plugins {{{
@@ -163,35 +162,36 @@ class Plugins(collections.Mapping):
def __init__(self):
self._plugins = {}
- plugins = [
- 'pictureflow',
- 'lzx',
- 'msdes',
- 'podofo',
- 'cPalmdoc',
- 'progress_indicator',
- 'chmlib',
- 'icu',
- 'speedup',
- 'html_as_json',
- 'unicode_names',
- 'html_syntax_highlighter',
- 'hyphen',
- 'freetype',
- 'imageops',
- 'hunspell',
- '_patiencediff_c',
- 'bzzdec',
- 'matcher',
- 'tokenizer',
- 'certgen',
- 'lzma_binding',
- ]
- if not ispy3:
- plugins.extend([
- 'monotonic',
- 'zlib2',
- ])
+ plugins = []
+ # plugins = [
+ # 'pictureflow',
+ # 'lzx',
+ # 'msdes',
+ # 'podofo',
+ # 'cPalmdoc',
+ # 'progress_indicator',
+ # 'chmlib',
+ # 'icu',
+ # 'speedup',
+ # 'html_as_json',
+ # 'unicode_names',
+ # 'html_syntax_highlighter',
+ # 'hyphen',
+ # 'freetype',
+ # 'imageops',
+ # 'hunspell',
+ # '_patiencediff_c',
+ # 'bzzdec',
+ # 'matcher',
+ # 'tokenizer',
+ # 'certgen',
+ # 'lzma_binding',
+ # ]
+ # if not ispy3:
+ # plugins.extend([
+ # 'monotonic',
+ # 'zlib2',
+ # ])
if iswindows:
plugins.extend(['winutil', 'wpd', 'winfonts'])
if isosx:
@@ -205,7 +205,7 @@ class Plugins(collections.Mapping):
def load_plugin(self, name):
if name in self._plugins:
return
- sys.path.insert(0, plugins_loc)
+ # sys.path.insert(0, plugins_loc)
try:
del sys.modules[name]
except KeyError:
@@ -220,7 +220,7 @@ class Plugins(collections.Mapping):
except Exception:
plugin_err = as_unicode(native_string_type(err), encoding=preferred_encoding, errors='replace')
self._plugins[name] = p, plugin_err
- sys.path.remove(plugins_loc)
+ # sys.path.remove(plugins_loc)
def __iter__(self):
return iter(self.plugins)
diff --git a/ebook_converter/css_selectors/__init__.py b/ebook_converter/css_selectors/__init__.py
index 24e1322..ecfe250 100644
--- a/ebook_converter/css_selectors/__init__.py
+++ b/ebook_converter/css_selectors/__init__.py
@@ -5,8 +5,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__license__ = 'GPL v3'
__copyright__ = '2015, Kovid Goyal '
-from css_selectors.parser import parse
-from css_selectors.select import Select, INAPPROPRIATE_PSEUDO_CLASSES
-from css_selectors.errors import SelectorError, SelectorSyntaxError, ExpressionError
+from ebook_converter.css_selectors.parser import parse
+from ebook_converter.css_selectors.select import Select, INAPPROPRIATE_PSEUDO_CLASSES
+from ebook_converter.css_selectors.errors import SelectorError, SelectorSyntaxError, ExpressionError
__all__ = ['parse', 'Select', 'INAPPROPRIATE_PSEUDO_CLASSES', 'SelectorError', 'SelectorSyntaxError', 'ExpressionError']
diff --git a/ebook_converter/css_selectors/ordered_set.py b/ebook_converter/css_selectors/ordered_set.py
index 448a4a7..ac18413 100644
--- a/ebook_converter/css_selectors/ordered_set.py
+++ b/ebook_converter/css_selectors/ordered_set.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2015, Kovid Goyal '
import collections
-from polyglot.builtins import string_or_bytes
+from ebook_converter.polyglot.builtins import string_or_bytes
SLICE_ALL = slice(None)
diff --git a/ebook_converter/css_selectors/parser.py b/ebook_converter/css_selectors/parser.py
index 4ea3e11..1a1dc90 100644
--- a/ebook_converter/css_selectors/parser.py
+++ b/ebook_converter/css_selectors/parser.py
@@ -14,8 +14,8 @@ import re
import operator
import string
-from css_selectors.errors import SelectorSyntaxError, ExpressionError
-from polyglot.builtins import unicode_type, codepoint_to_chr, range
+from ebook_converter.css_selectors.errors import SelectorSyntaxError, ExpressionError
+from ebook_converter.polyglot.builtins import unicode_type, codepoint_to_chr, range
utab = {c:c+32 for c in range(ord(u'A'), ord(u'Z')+1)}
diff --git a/ebook_converter/css_selectors/select.py b/ebook_converter/css_selectors/select.py
index b6e2a18..d1852ea 100644
--- a/ebook_converter/css_selectors/select.py
+++ b/ebook_converter/css_selectors/select.py
@@ -12,11 +12,11 @@ from itertools import chain
from lxml import etree
-from css_selectors.errors import ExpressionError
-from css_selectors.parser import parse, ascii_lower, Element, FunctionalPseudoElement
-from css_selectors.ordered_set import OrderedSet
+from ebook_converter.css_selectors.errors import ExpressionError
+from ebook_converter.css_selectors.parser import parse, ascii_lower, Element, FunctionalPseudoElement
+from ebook_converter.css_selectors.ordered_set import OrderedSet
-from polyglot.builtins import iteritems, itervalues
+from ebook_converter.polyglot.builtins import iteritems, itervalues
PARSE_CACHE_SIZE = 200
parse_cache = OrderedDict()
diff --git a/ebook_converter/css_selectors/tests.py b/ebook_converter/css_selectors/tests.py
index 0176f1d..86ce622 100644
--- a/ebook_converter/css_selectors/tests.py
+++ b/ebook_converter/css_selectors/tests.py
@@ -9,9 +9,9 @@ import unittest, sys, argparse
from lxml import etree, html
-from css_selectors.errors import SelectorSyntaxError, ExpressionError
-from css_selectors.parser import tokenize, parse
-from css_selectors.select import Select
+from ebook_converter.css_selectors.errors import SelectorSyntaxError, ExpressionError
+from ebook_converter.css_selectors.parser import tokenize, parse
+from ebook_converter.css_selectors.select import Select
class TestCSSSelectors(unittest.TestCase):
diff --git a/ebook_converter/customize/__init__.py b/ebook_converter/customize/__init__.py
index 8878fb8..83a6ec1 100644
--- a/ebook_converter/customize/__init__.py
+++ b/ebook_converter/customize/__init__.py
@@ -4,9 +4,9 @@ __copyright__ = '2008, Kovid Goyal '
import os, sys, zipfile, importlib
-from calibre.constants import numeric_version, iswindows, isosx
-from calibre.ptempfile import PersistentTemporaryFile
-from polyglot.builtins import unicode_type
+from ebook_converter.constants import numeric_version, iswindows, isosx
+from ebook_converter.ptempfile import PersistentTemporaryFile
+from ebook_converter.polyglot.builtins import unicode_type
platform = 'linux'
if iswindows:
@@ -134,7 +134,7 @@ class Plugin(object): # {{{
'''
from PyQt5.Qt import QDialog, QDialogButtonBox, QVBoxLayout, \
QLabel, Qt, QLineEdit
- from calibre.gui2 import gprefs
+ from ebook_converter.gui2 import gprefs
prefname = 'plugin config dialog:'+self.type + ':' + self.name
geom = gprefs.get(prefname, None)
@@ -159,7 +159,7 @@ class Plugin(object): # {{{
config_widget = None
if isinstance(config_widget, tuple):
- from calibre.gui2 import warning_dialog
+ from ebook_converter.gui2 import warning_dialog
warning_dialog(parent, _('Cannot configure'), config_widget[0],
det_msg=config_widget[1], show=True)
return False
@@ -177,7 +177,7 @@ class Plugin(object): # {{{
else:
self.save_settings(config_widget)
else:
- from calibre.customize.ui import plugin_customization, \
+ from ebook_converter.customize.ui import plugin_customization, \
customize_plugin
help_text = self.customization_help(gui=True)
help_text = QLabel(help_text, config_dialog)
@@ -276,7 +276,7 @@ class Plugin(object): # {{{
import something
'''
if self.plugin_path is not None:
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
zf = ZipFile(self.plugin_path)
extensions = {x.rpartition('.')[-1].lower() for x in
zf.namelist()}
@@ -289,7 +289,7 @@ class Plugin(object): # {{{
sys.path.insert(0, self.plugin_path)
self.sys_insertion_path = self.plugin_path
else:
- from calibre.ptempfile import TemporaryDirectory
+ from ebook_converter.ptempfile import TemporaryDirectory
self._sys_insertion_tdir = TemporaryDirectory('plugin_unzip')
self.sys_insertion_path = self._sys_insertion_tdir.__enter__(*args)
zf.extractall(self.sys_insertion_path)
@@ -426,7 +426,7 @@ class MetadataReaderPlugin(Plugin): # {{{
:param type: The type of file. Guaranteed to be one of the entries
in :attr:`file_types`.
- :return: A :class:`calibre.ebooks.metadata.book.Metadata` object
+ :return: A :class:`ebook_converter.ebooks.metadata.book.Metadata` object
'''
return None
# }}}
@@ -458,7 +458,7 @@ class MetadataWriterPlugin(Plugin): # {{{
:param type: The type of file. Guaranteed to be one of the entries
in :attr:`file_types`.
- :param mi: A :class:`calibre.ebooks.metadata.book.Metadata` object
+ :param mi: A :class:`ebook_converter.ebooks.metadata.book.Metadata` object
'''
pass
@@ -484,7 +484,7 @@ class CatalogPlugin(Plugin): # {{{
#: Option = namedtuple('Option', 'option, default, dest, help')
#: cli_options = [Option('--catalog-title', default = 'My Catalog',
#: dest = 'catalog_title', help = (_('Title of generated catalog. \nDefault:') + " '" + '%default' + "'"))]
- #: cli_options parsed in calibre.db.cli.cmd_catalog:option_parser()
+ #: cli_options parsed in ebook_converter.db.cli.cmd_catalog:option_parser()
#:
cli_options = []
@@ -526,7 +526,7 @@ class CatalogPlugin(Plugin): # {{{
# Validate requested_fields
if requested_fields - all_fields:
- from calibre.library import current_library_name
+ from ebook_converter.library import current_library_name
invalid_fields = sorted(list(requested_fields - all_fields))
print("invalid --fields specified: %s" % ', '.join(invalid_fields))
print("available fields in '%s': %s" %
@@ -547,11 +547,11 @@ class CatalogPlugin(Plugin): # {{{
If plugin is not a built-in, copy the plugin's .ui and .py files from
the ZIP file to $TMPDIR.
Tab will be dynamically generated and added to the Catalog Options dialog in
- calibre.gui2.dialogs.catalog.py:Catalog
+ ebook_converter.gui2.dialogs.catalog.py:Catalog
'''
- from calibre.customize.builtins import plugins as builtin_plugins
- from calibre.customize.ui import config
- from calibre.ptempfile import PersistentTemporaryDirectory
+ from ebook_converter.customize.builtins import plugins as builtin_plugins
+ from ebook_converter.customize.ui import config
+ from ebook_converter.ptempfile import PersistentTemporaryDirectory
if not type(self) in builtin_plugins and self.name not in config['disabled_plugins']:
files_to_copy = ["%s.%s" % (self.name.lower(),ext) for ext in ["ui","py"]]
@@ -663,7 +663,7 @@ class PreferencesPlugin(Plugin): # {{{
'''
Create and return the actual Qt widget used for setting this group of
preferences. The widget must implement the
- :class:`calibre.gui2.preferences.ConfigWidgetInterface`.
+ :class:`ebook_converter.gui2.preferences.ConfigWidgetInterface`.
The default implementation uses :attr:`config_widget` to instantiate
the widget.
diff --git a/ebook_converter/customize/builtins.py b/ebook_converter/customize/builtins.py
index 4a3af02..b824879 100644
--- a/ebook_converter/customize/builtins.py
+++ b/ebook_converter/customize/builtins.py
@@ -5,12 +5,12 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
import os, glob, re
-from calibre import guess_type
-from calibre.customize import (FileTypePlugin, MetadataReaderPlugin,
+from ebook_converter import guess_type
+from ebook_converter.customize import (FileTypePlugin, MetadataReaderPlugin,
MetadataWriterPlugin, PreferencesPlugin, InterfaceActionBase, StoreBase)
-from calibre.constants import numeric_version
-from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata
-from calibre.ebooks.html.to_zip import HTML2ZIP
+from ebook_converter.constants import numeric_version
+from ebook_converter.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata
+from ebook_converter.ebooks.html.to_zip import HTML2ZIP
plugins = []
@@ -60,7 +60,7 @@ class TXT2TXTZ(FileTypePlugin):
on_import = True
def _get_image_references(self, txt, base_dir):
- from calibre.ebooks.oeb.base import OEB_IMAGES
+ from ebook_converter.ebooks.oeb.base import OEB_IMAGES
images = []
@@ -90,7 +90,7 @@ class TXT2TXTZ(FileTypePlugin):
return list(set(images))
def run(self, path_to_ebook):
- from calibre.ebooks.metadata.opf2 import metadata_to_opf
+ from ebook_converter.ebooks.metadata.opf2 import metadata_to_opf
with open(path_to_ebook, 'rb') as ebf:
txt = ebf.read().decode('utf-8', 'replace')
@@ -108,7 +108,7 @@ class TXT2TXTZ(FileTypePlugin):
if os.path.exists(os.path.join(base_dir, 'metadata.opf')):
txtz.write(os.path.join(base_dir, 'metadata.opf'), 'metadata.opf', zipfile.ZIP_DEFLATED)
else:
- from calibre.ebooks.metadata.txt import get_metadata
+ from ebook_converter.ebooks.metadata.txt import get_metadata
with open(path_to_ebook, 'rb') as ebf:
mi = get_metadata(ebf)
opf = metadata_to_opf(mi)
@@ -149,10 +149,10 @@ class ComicMetadataReader(MetadataReaderPlugin):
elif id_.startswith(b'PK'):
ftype = 'cbz'
if ftype == 'cbr':
- from calibre.utils.unrar import extract_cover_image
+ from ebook_converter.utils.unrar import extract_cover_image
else:
- from calibre.libunzip import extract_cover_image
- from calibre.ebooks.metadata import MetaInformation
+ from ebook_converter.libunzip import extract_cover_image
+ from ebook_converter.ebooks.metadata import MetaInformation
ret = extract_cover_image(stream)
mi = MetaInformation(None, None)
stream.seek(0)
@@ -178,7 +178,7 @@ class CHMMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files') % 'CHM'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.chm.metadata import get_metadata
+ from ebook_converter.ebooks.chm.metadata import get_metadata
return get_metadata(stream)
@@ -189,7 +189,7 @@ class EPUBMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'EPUB'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.epub import get_metadata, get_quick_metadata
+ from ebook_converter.ebooks.metadata.epub import get_metadata, get_quick_metadata
if self.quick:
return get_quick_metadata(stream)
return get_metadata(stream)
@@ -202,7 +202,7 @@ class FB2MetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'FB2'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.fb2 import get_metadata
+ from ebook_converter.ebooks.metadata.fb2 import get_metadata
return get_metadata(stream)
@@ -213,7 +213,7 @@ class HTMLMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'HTML'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.html import get_metadata
+ from ebook_converter.ebooks.metadata.html import get_metadata
return get_metadata(stream)
@@ -225,7 +225,7 @@ class HTMLZMetadataReader(MetadataReaderPlugin):
author = 'John Schember'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.extz import get_metadata
+ from ebook_converter.ebooks.metadata.extz import get_metadata
return get_metadata(stream)
@@ -237,7 +237,7 @@ class IMPMetadataReader(MetadataReaderPlugin):
author = 'Ashish Kulkarni'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.imp import get_metadata
+ from ebook_converter.ebooks.metadata.imp import get_metadata
return get_metadata(stream)
@@ -248,7 +248,7 @@ class LITMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'LIT'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.lit import get_metadata
+ from ebook_converter.ebooks.metadata.lit import get_metadata
return get_metadata(stream)
@@ -259,7 +259,7 @@ class LRFMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'LRF'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.lrf.meta import get_metadata
+ from ebook_converter.ebooks.lrf.meta import get_metadata
return get_metadata(stream)
@@ -270,7 +270,7 @@ class LRXMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'LRX'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.lrx import get_metadata
+ from ebook_converter.ebooks.metadata.lrx import get_metadata
return get_metadata(stream)
@@ -281,7 +281,7 @@ class MOBIMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'MOBI'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.mobi import get_metadata
+ from ebook_converter.ebooks.metadata.mobi import get_metadata
return get_metadata(stream)
@@ -292,7 +292,7 @@ class ODTMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'ODT'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.odt import get_metadata
+ from ebook_converter.ebooks.metadata.odt import get_metadata
return get_metadata(stream)
@@ -303,7 +303,7 @@ class DocXMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'DOCX'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.docx import get_metadata
+ from ebook_converter.ebooks.metadata.docx import get_metadata
return get_metadata(stream)
@@ -314,7 +314,7 @@ class OPFMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'OPF'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.opf import get_metadata
+ from ebook_converter.ebooks.metadata.opf import get_metadata
return get_metadata(stream)[0]
@@ -326,7 +326,7 @@ class PDBMetadataReader(MetadataReaderPlugin):
author = 'John Schember'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.pdb import get_metadata
+ from ebook_converter.ebooks.metadata.pdb import get_metadata
return get_metadata(stream)
@@ -337,7 +337,7 @@ class PDFMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'PDF'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.pdf import get_metadata, get_quick_metadata
+ from ebook_converter.ebooks.metadata.pdf import get_metadata, get_quick_metadata
if self.quick:
return get_quick_metadata(stream)
return get_metadata(stream)
@@ -351,7 +351,7 @@ class PMLMetadataReader(MetadataReaderPlugin):
author = 'John Schember'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.pml import get_metadata
+ from ebook_converter.ebooks.metadata.pml import get_metadata
return get_metadata(stream)
@@ -362,7 +362,7 @@ class RARMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from e-books in RAR archives')
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.rar import get_metadata
+ from ebook_converter.ebooks.metadata.rar import get_metadata
return get_metadata(stream)
@@ -374,7 +374,7 @@ class RBMetadataReader(MetadataReaderPlugin):
author = 'Ashish Kulkarni'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.rb import get_metadata
+ from ebook_converter.ebooks.metadata.rb import get_metadata
return get_metadata(stream)
@@ -385,7 +385,7 @@ class RTFMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'RTF'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.rtf import get_metadata
+ from ebook_converter.ebooks.metadata.rtf import get_metadata
return get_metadata(stream)
@@ -397,7 +397,7 @@ class SNBMetadataReader(MetadataReaderPlugin):
author = 'Li Fanxi'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.snb import get_metadata
+ from ebook_converter.ebooks.metadata.snb import get_metadata
return get_metadata(stream)
@@ -408,7 +408,7 @@ class TOPAZMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from %s files')%'MOBI'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.topaz import get_metadata
+ from ebook_converter.ebooks.metadata.topaz import get_metadata
return get_metadata(stream)
@@ -420,7 +420,7 @@ class TXTMetadataReader(MetadataReaderPlugin):
author = 'John Schember'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.txt import get_metadata
+ from ebook_converter.ebooks.metadata.txt import get_metadata
return get_metadata(stream)
@@ -432,7 +432,7 @@ class TXTZMetadataReader(MetadataReaderPlugin):
author = 'John Schember'
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.extz import get_metadata
+ from ebook_converter.ebooks.metadata.extz import get_metadata
return get_metadata(stream)
@@ -443,7 +443,7 @@ class ZipMetadataReader(MetadataReaderPlugin):
description = _('Read metadata from e-books in ZIP archives')
def get_metadata(self, stream, ftype):
- from calibre.ebooks.metadata.zip import get_metadata
+ from ebook_converter.ebooks.metadata.zip import get_metadata
return get_metadata(stream)
@@ -462,7 +462,7 @@ class EPUBMetadataWriter(MetadataWriterPlugin):
description = _('Set metadata in %s files')%'EPUB'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.epub import set_metadata
+ from ebook_converter.ebooks.metadata.epub import set_metadata
q = self.site_customization or ''
set_metadata(stream, mi, apply_null=self.apply_null, force_identifiers=self.force_identifiers, add_missing_cover='disable-add-missing-cover' != q)
@@ -481,7 +481,7 @@ class FB2MetadataWriter(MetadataWriterPlugin):
description = _('Set metadata in %s files')%'FB2'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.fb2 import set_metadata
+ from ebook_converter.ebooks.metadata.fb2 import set_metadata
set_metadata(stream, mi, apply_null=self.apply_null)
@@ -493,7 +493,7 @@ class HTMLZMetadataWriter(MetadataWriterPlugin):
author = 'John Schember'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.extz import set_metadata
+ from ebook_converter.ebooks.metadata.extz import set_metadata
set_metadata(stream, mi)
@@ -504,7 +504,7 @@ class LRFMetadataWriter(MetadataWriterPlugin):
description = _('Set metadata in %s files')%'LRF'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.lrf.meta import set_metadata
+ from ebook_converter.ebooks.lrf.meta import set_metadata
set_metadata(stream, mi)
@@ -516,7 +516,7 @@ class MOBIMetadataWriter(MetadataWriterPlugin):
author = 'Marshall T. Vandegrift'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.mobi import set_metadata
+ from ebook_converter.ebooks.metadata.mobi import set_metadata
set_metadata(stream, mi)
@@ -528,7 +528,7 @@ class PDBMetadataWriter(MetadataWriterPlugin):
author = 'John Schember'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.pdb import set_metadata
+ from ebook_converter.ebooks.metadata.pdb import set_metadata
set_metadata(stream, mi)
@@ -540,7 +540,7 @@ class PDFMetadataWriter(MetadataWriterPlugin):
author = 'Kovid Goyal'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.pdf import set_metadata
+ from ebook_converter.ebooks.metadata.pdf import set_metadata
set_metadata(stream, mi)
@@ -551,7 +551,7 @@ class RTFMetadataWriter(MetadataWriterPlugin):
description = _('Set metadata in %s files')%'RTF'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.rtf import set_metadata
+ from ebook_converter.ebooks.metadata.rtf import set_metadata
set_metadata(stream, mi)
@@ -563,7 +563,7 @@ class TOPAZMetadataWriter(MetadataWriterPlugin):
author = 'Greg Riker'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.topaz import set_metadata
+ from ebook_converter.ebooks.metadata.topaz import set_metadata
set_metadata(stream, mi)
@@ -575,7 +575,7 @@ class TXTZMetadataWriter(MetadataWriterPlugin):
author = 'John Schember'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.extz import set_metadata
+ from ebook_converter.ebooks.metadata.extz import set_metadata
set_metadata(stream, mi)
@@ -586,7 +586,7 @@ class ODTMetadataWriter(MetadataWriterPlugin):
description = _('Set metadata from %s files')%'ODT'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.odt import set_metadata
+ from ebook_converter.ebooks.metadata.odt import set_metadata
return set_metadata(stream, mi)
@@ -597,7 +597,7 @@ class DocXMetadataWriter(MetadataWriterPlugin):
description = _('Set metadata from %s files')%'DOCX'
def set_metadata(self, stream, mi, type):
- from calibre.ebooks.metadata.docx import set_metadata
+ from ebook_converter.ebooks.metadata.docx import set_metadata
return set_metadata(stream, mi)
@@ -607,47 +607,47 @@ plugins += [x for x in list(locals().values()) if isinstance(x, type) and
# }}}
# Conversion plugins {{{
-from calibre.ebooks.conversion.plugins.comic_input import ComicInput
-from calibre.ebooks.conversion.plugins.djvu_input import DJVUInput
-from calibre.ebooks.conversion.plugins.epub_input import EPUBInput
-from calibre.ebooks.conversion.plugins.fb2_input import FB2Input
-from calibre.ebooks.conversion.plugins.html_input import HTMLInput
-from calibre.ebooks.conversion.plugins.htmlz_input import HTMLZInput
-from calibre.ebooks.conversion.plugins.lit_input import LITInput
-from calibre.ebooks.conversion.plugins.mobi_input import MOBIInput
-from calibre.ebooks.conversion.plugins.odt_input import ODTInput
-from calibre.ebooks.conversion.plugins.pdb_input import PDBInput
-from calibre.ebooks.conversion.plugins.azw4_input import AZW4Input
-from calibre.ebooks.conversion.plugins.pdf_input import PDFInput
-from calibre.ebooks.conversion.plugins.pml_input import PMLInput
-from calibre.ebooks.conversion.plugins.rb_input import RBInput
-from calibre.ebooks.conversion.plugins.recipe_input import RecipeInput
-from calibre.ebooks.conversion.plugins.rtf_input import RTFInput
-from calibre.ebooks.conversion.plugins.tcr_input import TCRInput
-from calibre.ebooks.conversion.plugins.txt_input import TXTInput
-from calibre.ebooks.conversion.plugins.lrf_input import LRFInput
-from calibre.ebooks.conversion.plugins.chm_input import CHMInput
-from calibre.ebooks.conversion.plugins.snb_input import SNBInput
-from calibre.ebooks.conversion.plugins.docx_input import DOCXInput
+from ebook_converter.ebooks.conversion.plugins.comic_input import ComicInput
+from ebook_converter.ebooks.conversion.plugins.djvu_input import DJVUInput
+from ebook_converter.ebooks.conversion.plugins.epub_input import EPUBInput
+from ebook_converter.ebooks.conversion.plugins.fb2_input import FB2Input
+from ebook_converter.ebooks.conversion.plugins.html_input import HTMLInput
+from ebook_converter.ebooks.conversion.plugins.htmlz_input import HTMLZInput
+from ebook_converter.ebooks.conversion.plugins.lit_input import LITInput
+from ebook_converter.ebooks.conversion.plugins.mobi_input import MOBIInput
+from ebook_converter.ebooks.conversion.plugins.odt_input import ODTInput
+from ebook_converter.ebooks.conversion.plugins.pdb_input import PDBInput
+from ebook_converter.ebooks.conversion.plugins.azw4_input import AZW4Input
+from ebook_converter.ebooks.conversion.plugins.pdf_input import PDFInput
+from ebook_converter.ebooks.conversion.plugins.pml_input import PMLInput
+from ebook_converter.ebooks.conversion.plugins.rb_input import RBInput
+from ebook_converter.ebooks.conversion.plugins.recipe_input import RecipeInput
+from ebook_converter.ebooks.conversion.plugins.rtf_input import RTFInput
+from ebook_converter.ebooks.conversion.plugins.tcr_input import TCRInput
+from ebook_converter.ebooks.conversion.plugins.txt_input import TXTInput
+from ebook_converter.ebooks.conversion.plugins.lrf_input import LRFInput
+from ebook_converter.ebooks.conversion.plugins.chm_input import CHMInput
+from ebook_converter.ebooks.conversion.plugins.snb_input import SNBInput
+from ebook_converter.ebooks.conversion.plugins.docx_input import DOCXInput
-from calibre.ebooks.conversion.plugins.epub_output import EPUBOutput
-from calibre.ebooks.conversion.plugins.fb2_output import FB2Output
-from calibre.ebooks.conversion.plugins.lit_output import LITOutput
-from calibre.ebooks.conversion.plugins.lrf_output import LRFOutput
-from calibre.ebooks.conversion.plugins.mobi_output import (MOBIOutput,
+from ebook_converter.ebooks.conversion.plugins.epub_output import EPUBOutput
+from ebook_converter.ebooks.conversion.plugins.fb2_output import FB2Output
+from ebook_converter.ebooks.conversion.plugins.lit_output import LITOutput
+from ebook_converter.ebooks.conversion.plugins.lrf_output import LRFOutput
+from ebook_converter.ebooks.conversion.plugins.mobi_output import (MOBIOutput,
AZW3Output)
-from calibre.ebooks.conversion.plugins.oeb_output import OEBOutput
-from calibre.ebooks.conversion.plugins.pdb_output import PDBOutput
-from calibre.ebooks.conversion.plugins.pdf_output import PDFOutput
-from calibre.ebooks.conversion.plugins.pml_output import PMLOutput
-from calibre.ebooks.conversion.plugins.rb_output import RBOutput
-from calibre.ebooks.conversion.plugins.rtf_output import RTFOutput
-from calibre.ebooks.conversion.plugins.tcr_output import TCROutput
-from calibre.ebooks.conversion.plugins.txt_output import TXTOutput, TXTZOutput
-from calibre.ebooks.conversion.plugins.html_output import HTMLOutput
-from calibre.ebooks.conversion.plugins.htmlz_output import HTMLZOutput
-from calibre.ebooks.conversion.plugins.snb_output import SNBOutput
-from calibre.ebooks.conversion.plugins.docx_output import DOCXOutput
+from ebook_converter.ebooks.conversion.plugins.oeb_output import OEBOutput
+from ebook_converter.ebooks.conversion.plugins.pdb_output import PDBOutput
+from ebook_converter.ebooks.conversion.plugins.pdf_output import PDFOutput
+from ebook_converter.ebooks.conversion.plugins.pml_output import PMLOutput
+from ebook_converter.ebooks.conversion.plugins.rb_output import RBOutput
+from ebook_converter.ebooks.conversion.plugins.rtf_output import RTFOutput
+from ebook_converter.ebooks.conversion.plugins.tcr_output import TCROutput
+from ebook_converter.ebooks.conversion.plugins.txt_output import TXTOutput, TXTZOutput
+from ebook_converter.ebooks.conversion.plugins.html_output import HTMLOutput
+from ebook_converter.ebooks.conversion.plugins.htmlz_output import HTMLZOutput
+from ebook_converter.ebooks.conversion.plugins.snb_output import SNBOutput
+from ebook_converter.ebooks.conversion.plugins.docx_output import DOCXOutput
plugins += [
ComicInput,
@@ -696,145 +696,145 @@ plugins += [
# }}}
# Catalog plugins {{{
-from calibre.library.catalogs.csv_xml import CSV_XML
-from calibre.library.catalogs.bibtex import BIBTEX
-from calibre.library.catalogs.epub_mobi import EPUB_MOBI
+from ebook_converter.library.catalogs.csv_xml import CSV_XML
+from ebook_converter.library.catalogs.bibtex import BIBTEX
+from ebook_converter.library.catalogs.epub_mobi import EPUB_MOBI
plugins += [CSV_XML, BIBTEX, EPUB_MOBI]
# }}}
# Profiles {{{
-from calibre.customize.profiles import input_profiles, output_profiles
+from ebook_converter.customize.profiles import input_profiles, output_profiles
plugins += input_profiles + output_profiles
# }}}
# Device driver plugins {{{
-from calibre.devices.hanlin.driver import HANLINV3, HANLINV5, BOOX, SPECTRA
-from calibre.devices.blackberry.driver import BLACKBERRY, PLAYBOOK
-from calibre.devices.cybook.driver import CYBOOK, ORIZON, MUSE, DIVA
-from calibre.devices.eb600.driver import (EB600, COOL_ER, SHINEBOOK, TOLINO,
- POCKETBOOK360, GER2, ITALICA, ECLICTO, DBOOK, INVESBOOK,
- BOOQ, ELONEX, POCKETBOOK301, MENTOR, POCKETBOOK602,
- POCKETBOOK701, POCKETBOOK740, POCKETBOOK360P, PI2, POCKETBOOK622,
- POCKETBOOKHD)
-from calibre.devices.iliad.driver import ILIAD
-from calibre.devices.irexdr.driver import IREXDR1000, IREXDR800
-from calibre.devices.jetbook.driver import (JETBOOK, MIBUK, JETBOOK_MINI,
- JETBOOK_COLOR)
-from calibre.devices.kindle.driver import (KINDLE, KINDLE2, KINDLE_DX,
- KINDLE_FIRE)
-from calibre.devices.nook.driver import NOOK, NOOK_COLOR
-from calibre.devices.prs505.driver import PRS505
-from calibre.devices.prst1.driver import PRST1
-from calibre.devices.user_defined.driver import USER_DEFINED
-from calibre.devices.android.driver import ANDROID, S60, WEBOS
-from calibre.devices.nokia.driver import N770, N810, E71X, E52
-from calibre.devices.eslick.driver import ESLICK, EBK52
-from calibre.devices.nuut2.driver import NUUT2
-from calibre.devices.iriver.driver import IRIVER_STORY
-from calibre.devices.binatone.driver import README
-from calibre.devices.hanvon.driver import (N516, EB511, ALEX, AZBOOKA, THEBOOK,
- LIBREAIR, ODYSSEY, KIBANO)
-from calibre.devices.edge.driver import EDGE
-from calibre.devices.teclast.driver import (TECLAST_K3, NEWSMY, IPAPYRUS,
- SOVOS, PICO, SUNSTECH_EB700, ARCHOS7O, STASH, WEXLER)
-from calibre.devices.sne.driver import SNE
-from calibre.devices.misc import (
- PALMPRE, AVANT, SWEEX, PDNOVEL, GEMEI, VELOCITYMICRO, PDNOVEL_KOBO,
- LUMIREAD, ALURATEK_COLOR, TREKSTOR, EEEREADER, NEXTBOOK, ADAM, MOOVYBOOK,
- COBY, EX124G, WAYTEQ, WOXTER, POCKETBOOK626, SONYDPTS1, CERVANTES)
-from calibre.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG
-from calibre.devices.kobo.driver import KOBO, KOBOTOUCH
-from calibre.devices.boeye.driver import BOEYE_BEX, BOEYE_BDX
-from calibre.devices.smart_device_app.driver import SMART_DEVICE_APP
-from calibre.devices.mtp.driver import MTP_DEVICE
+#from ebook_converter.devices.hanlin.driver import HANLINV3, HANLINV5, BOOX, SPECTRA
+#from ebook_converter.devices.blackberry.driver import BLACKBERRY, PLAYBOOK
+#from ebook_converter.devices.cybook.driver import CYBOOK, ORIZON, MUSE, DIVA
+#from ebook_converter.devices.eb600.driver import (EB600, COOL_ER, SHINEBOOK, TOLINO,
+# POCKETBOOK360, GER2, ITALICA, ECLICTO, DBOOK, INVESBOOK,
+# BOOQ, ELONEX, POCKETBOOK301, MENTOR, POCKETBOOK602,
+# POCKETBOOK701, POCKETBOOK740, POCKETBOOK360P, PI2, POCKETBOOK622,
+# POCKETBOOKHD)
+#from ebook_converter.devices.iliad.driver import ILIAD
+#from ebook_converter.devices.irexdr.driver import IREXDR1000, IREXDR800
+#from ebook_converter.devices.jetbook.driver import (JETBOOK, MIBUK, JETBOOK_MINI,
+# JETBOOK_COLOR)
+#from ebook_converter.devices.kindle.driver import (KINDLE, KINDLE2, KINDLE_DX,
+# KINDLE_FIRE)
+#from ebook_converter.devices.nook.driver import NOOK, NOOK_COLOR
+#from ebook_converter.devices.prs505.driver import PRS505
+#from ebook_converter.devices.prst1.driver import PRST1
+#from ebook_converter.devices.user_defined.driver import USER_DEFINED
+#from ebook_converter.devices.android.driver import ANDROID, S60, WEBOS
+#from ebook_converter.devices.nokia.driver import N770, N810, E71X, E52
+#from ebook_converter.devices.eslick.driver import ESLICK, EBK52
+#from ebook_converter.devices.nuut2.driver import NUUT2
+#from ebook_converter.devices.iriver.driver import IRIVER_STORY
+#from ebook_converter.devices.binatone.driver import README
+#from ebook_converter.devices.hanvon.driver import (N516, EB511, ALEX, AZBOOKA, THEBOOK,
+# LIBREAIR, ODYSSEY, KIBANO)
+#from ebook_converter.devices.edge.driver import EDGE
+#from ebook_converter.devices.teclast.driver import (TECLAST_K3, NEWSMY, IPAPYRUS,
+# SOVOS, PICO, SUNSTECH_EB700, ARCHOS7O, STASH, WEXLER)
+#from ebook_converter.devices.sne.driver import SNE
+#from ebook_converter.devices.misc import (
+# PALMPRE, AVANT, SWEEX, PDNOVEL, GEMEI, VELOCITYMICRO, PDNOVEL_KOBO,
+# LUMIREAD, ALURATEK_COLOR, TREKSTOR, EEEREADER, NEXTBOOK, ADAM, MOOVYBOOK,
+# COBY, EX124G, WAYTEQ, WOXTER, POCKETBOOK626, SONYDPTS1, CERVANTES)
+#from ebook_converter.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG
+#from ebook_converter.devices.kobo.driver import KOBO, KOBOTOUCH
+#from ebook_converter.devices.boeye.driver import BOEYE_BEX, BOEYE_BDX
+#from ebook_converter.devices.smart_device_app.driver import SMART_DEVICE_APP
+#from ebook_converter.devices.mtp.driver import MTP_DEVICE
# Order here matters. The first matched device is the one used.
-plugins += [
- HANLINV3,
- HANLINV5,
- BLACKBERRY, PLAYBOOK,
- CYBOOK, ORIZON, MUSE, DIVA,
- ILIAD,
- IREXDR1000,
- IREXDR800,
- JETBOOK, JETBOOK_MINI, MIBUK, JETBOOK_COLOR,
- SHINEBOOK,
- POCKETBOOK360, POCKETBOOK301, POCKETBOOK602, POCKETBOOK701, POCKETBOOK360P,
- POCKETBOOK622, PI2, POCKETBOOKHD, POCKETBOOK740,
- KINDLE, KINDLE2, KINDLE_DX, KINDLE_FIRE,
- NOOK, NOOK_COLOR,
- PRS505, PRST1,
- ANDROID, S60, WEBOS,
- N770,
- E71X,
- E52,
- N810,
- COOL_ER,
- ESLICK,
- EBK52,
- NUUT2,
- IRIVER_STORY,
- GER2,
- ITALICA,
- ECLICTO,
- DBOOK,
- INVESBOOK,
- BOOX,
- BOOQ,
- EB600, TOLINO,
- README,
- N516, KIBANO,
- THEBOOK, LIBREAIR,
- EB511,
- ELONEX,
- TECLAST_K3,
- NEWSMY,
- PICO, SUNSTECH_EB700, ARCHOS7O, SOVOS, STASH, WEXLER,
- IPAPYRUS,
- EDGE,
- SNE,
- ALEX, ODYSSEY,
- PALMPRE,
- KOBO, KOBOTOUCH,
- AZBOOKA,
- FOLDER_DEVICE_FOR_CONFIG,
- AVANT, CERVANTES,
- MENTOR,
- SWEEX,
- PDNOVEL,
- SPECTRA,
- GEMEI,
- VELOCITYMICRO,
- PDNOVEL_KOBO,
- LUMIREAD,
- ALURATEK_COLOR,
- TREKSTOR,
- EEEREADER,
- NEXTBOOK,
- ADAM,
- MOOVYBOOK, COBY, EX124G, WAYTEQ, WOXTER, POCKETBOOK626, SONYDPTS1,
- BOEYE_BEX,
- BOEYE_BDX,
- MTP_DEVICE,
- SMART_DEVICE_APP,
- USER_DEFINED,
-]
+#plugins += [
+# HANLINV3,
+# HANLINV5,
+# BLACKBERRY, PLAYBOOK,
+# CYBOOK, ORIZON, MUSE, DIVA,
+# ILIAD,
+# IREXDR1000,
+# IREXDR800,
+# JETBOOK, JETBOOK_MINI, MIBUK, JETBOOK_COLOR,
+# SHINEBOOK,
+# POCKETBOOK360, POCKETBOOK301, POCKETBOOK602, POCKETBOOK701, POCKETBOOK360P,
+# POCKETBOOK622, PI2, POCKETBOOKHD, POCKETBOOK740,
+# KINDLE, KINDLE2, KINDLE_DX, KINDLE_FIRE,
+# NOOK, NOOK_COLOR,
+# PRS505, PRST1,
+# ANDROID, S60, WEBOS,
+# N770,
+# E71X,
+# E52,
+# N810,
+# COOL_ER,
+# ESLICK,
+# EBK52,
+# NUUT2,
+# IRIVER_STORY,
+# GER2,
+# ITALICA,
+# ECLICTO,
+# DBOOK,
+# INVESBOOK,
+# BOOX,
+# BOOQ,
+# EB600, TOLINO,
+# README,
+# N516, KIBANO,
+# THEBOOK, LIBREAIR,
+# EB511,
+# ELONEX,
+# TECLAST_K3,
+# NEWSMY,
+# PICO, SUNSTECH_EB700, ARCHOS7O, SOVOS, STASH, WEXLER,
+# IPAPYRUS,
+# EDGE,
+# SNE,
+# ALEX, ODYSSEY,
+# PALMPRE,
+# KOBO, KOBOTOUCH,
+# AZBOOKA,
+# FOLDER_DEVICE_FOR_CONFIG,
+# AVANT, CERVANTES,
+# MENTOR,
+# SWEEX,
+# PDNOVEL,
+# SPECTRA,
+# GEMEI,
+# VELOCITYMICRO,
+# PDNOVEL_KOBO,
+# LUMIREAD,
+# ALURATEK_COLOR,
+# TREKSTOR,
+# EEEREADER,
+# NEXTBOOK,
+# ADAM,
+# MOOVYBOOK, COBY, EX124G, WAYTEQ, WOXTER, POCKETBOOK626, SONYDPTS1,
+# BOEYE_BEX,
+# BOEYE_BDX,
+# MTP_DEVICE,
+# SMART_DEVICE_APP,
+# USER_DEFINED,
+#]
# }}}
# New metadata download plugins {{{
-from calibre.ebooks.metadata.sources.google import GoogleBooks
-from calibre.ebooks.metadata.sources.amazon import Amazon
-from calibre.ebooks.metadata.sources.edelweiss import Edelweiss
-from calibre.ebooks.metadata.sources.openlibrary import OpenLibrary
-from calibre.ebooks.metadata.sources.overdrive import OverDrive
-from calibre.ebooks.metadata.sources.douban import Douban
-from calibre.ebooks.metadata.sources.ozon import Ozon
-from calibre.ebooks.metadata.sources.google_images import GoogleImages
-from calibre.ebooks.metadata.sources.big_book_search import BigBookSearch
-
-plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, OverDrive, Douban, Ozon, BigBookSearch]
+#from ebook_converter.ebooks.metadata.sources.google import GoogleBooks
+#from ebook_converter.ebooks.metadata.sources.amazon import Amazon
+#from ebook_converter.ebooks.metadata.sources.edelweiss import Edelweiss
+#from ebook_converter.ebooks.metadata.sources.openlibrary import OpenLibrary
+#from ebook_converter.ebooks.metadata.sources.overdrive import OverDrive
+#from ebook_converter.ebooks.metadata.sources.douban import Douban
+#from ebook_converter.ebooks.metadata.sources.ozon import Ozon
+#from ebook_converter.ebooks.metadata.sources.google_images import GoogleImages
+#from ebook_converter.ebooks.metadata.sources.big_book_search import BigBookSearch
+#
+#plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, OverDrive, Douban, Ozon, BigBookSearch]
# }}}
@@ -843,246 +843,246 @@ plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, OverDrive
class ActionAdd(InterfaceActionBase):
name = 'Add Books'
- actual_plugin = 'calibre.gui2.actions.add:AddAction'
+ actual_plugin = 'ebook_converter.gui2.actions.add:AddAction'
description = _('Add books to calibre or the connected device')
class ActionFetchAnnotations(InterfaceActionBase):
name = 'Fetch Annotations'
- actual_plugin = 'calibre.gui2.actions.annotate:FetchAnnotationsAction'
+ actual_plugin = 'ebook_converter.gui2.actions.annotate:FetchAnnotationsAction'
description = _('Fetch annotations from a connected Kindle (experimental)')
class ActionGenerateCatalog(InterfaceActionBase):
name = 'Generate Catalog'
- actual_plugin = 'calibre.gui2.actions.catalog:GenerateCatalogAction'
+ actual_plugin = 'ebook_converter.gui2.actions.catalog:GenerateCatalogAction'
description = _('Generate a catalog of the books in your calibre library')
class ActionConvert(InterfaceActionBase):
name = 'Convert Books'
- actual_plugin = 'calibre.gui2.actions.convert:ConvertAction'
+ actual_plugin = 'ebook_converter.gui2.actions.convert:ConvertAction'
description = _('Convert books to various e-book formats')
class ActionPolish(InterfaceActionBase):
name = 'Polish Books'
- actual_plugin = 'calibre.gui2.actions.polish:PolishAction'
+ actual_plugin = 'ebook_converter.gui2.actions.polish:PolishAction'
description = _('Fine tune your e-books')
class ActionEditToC(InterfaceActionBase):
name = 'Edit ToC'
- actual_plugin = 'calibre.gui2.actions.toc_edit:ToCEditAction'
+ actual_plugin = 'ebook_converter.gui2.actions.toc_edit:ToCEditAction'
description = _('Edit the Table of Contents in your books')
class ActionDelete(InterfaceActionBase):
name = 'Remove Books'
- actual_plugin = 'calibre.gui2.actions.delete:DeleteAction'
+ actual_plugin = 'ebook_converter.gui2.actions.delete:DeleteAction'
description = _('Delete books from your calibre library or connected device')
class ActionEmbed(InterfaceActionBase):
name = 'Embed Metadata'
- actual_plugin = 'calibre.gui2.actions.embed:EmbedAction'
+ actual_plugin = 'ebook_converter.gui2.actions.embed:EmbedAction'
description = _('Embed updated metadata into the actual book files in your calibre library')
class ActionEditMetadata(InterfaceActionBase):
name = 'Edit Metadata'
- actual_plugin = 'calibre.gui2.actions.edit_metadata:EditMetadataAction'
+ actual_plugin = 'ebook_converter.gui2.actions.edit_metadata:EditMetadataAction'
description = _('Edit the metadata of books in your calibre library')
class ActionView(InterfaceActionBase):
name = 'View'
- actual_plugin = 'calibre.gui2.actions.view:ViewAction'
+ actual_plugin = 'ebook_converter.gui2.actions.view:ViewAction'
description = _('Read books in your calibre library')
class ActionFetchNews(InterfaceActionBase):
name = 'Fetch News'
- actual_plugin = 'calibre.gui2.actions.fetch_news:FetchNewsAction'
+ actual_plugin = 'ebook_converter.gui2.actions.fetch_news:FetchNewsAction'
description = _('Download news from the internet in e-book form')
class ActionQuickview(InterfaceActionBase):
name = 'Quickview'
- actual_plugin = 'calibre.gui2.actions.show_quickview:ShowQuickviewAction'
+ actual_plugin = 'ebook_converter.gui2.actions.show_quickview:ShowQuickviewAction'
description = _('Show a list of related books quickly')
class ActionTagMapper(InterfaceActionBase):
name = 'Tag Mapper'
- actual_plugin = 'calibre.gui2.actions.tag_mapper:TagMapAction'
+ actual_plugin = 'ebook_converter.gui2.actions.tag_mapper:TagMapAction'
description = _('Filter/transform the tags for books in the library')
class ActionAuthorMapper(InterfaceActionBase):
name = 'Author Mapper'
- actual_plugin = 'calibre.gui2.actions.author_mapper:AuthorMapAction'
+ actual_plugin = 'ebook_converter.gui2.actions.author_mapper:AuthorMapAction'
description = _('Transform the authors for books in the library')
class ActionTemplateTester(InterfaceActionBase):
name = 'Template Tester'
- actual_plugin = 'calibre.gui2.actions.show_template_tester:ShowTemplateTesterAction'
+ actual_plugin = 'ebook_converter.gui2.actions.show_template_tester:ShowTemplateTesterAction'
description = _('Show an editor for testing templates')
class ActionSaveToDisk(InterfaceActionBase):
name = 'Save To Disk'
- actual_plugin = 'calibre.gui2.actions.save_to_disk:SaveToDiskAction'
+ actual_plugin = 'ebook_converter.gui2.actions.save_to_disk:SaveToDiskAction'
description = _('Export books from your calibre library to the hard disk')
class ActionShowBookDetails(InterfaceActionBase):
name = 'Show Book Details'
- actual_plugin = 'calibre.gui2.actions.show_book_details:ShowBookDetailsAction'
+ actual_plugin = 'ebook_converter.gui2.actions.show_book_details:ShowBookDetailsAction'
description = _('Show Book details in a separate popup')
class ActionRestart(InterfaceActionBase):
name = 'Restart'
- actual_plugin = 'calibre.gui2.actions.restart:RestartAction'
+ actual_plugin = 'ebook_converter.gui2.actions.restart:RestartAction'
description = _('Restart calibre')
class ActionOpenFolder(InterfaceActionBase):
name = 'Open Folder'
- actual_plugin = 'calibre.gui2.actions.open:OpenFolderAction'
+ actual_plugin = 'ebook_converter.gui2.actions.open:OpenFolderAction'
description = _('Open the folder that contains the book files in your'
' calibre library')
class ActionSendToDevice(InterfaceActionBase):
name = 'Send To Device'
- actual_plugin = 'calibre.gui2.actions.device:SendToDeviceAction'
+ actual_plugin = 'ebook_converter.gui2.actions.device:SendToDeviceAction'
description = _('Send books to the connected device')
class ActionConnectShare(InterfaceActionBase):
name = 'Connect Share'
- actual_plugin = 'calibre.gui2.actions.device:ConnectShareAction'
+ actual_plugin = 'ebook_converter.gui2.actions.device:ConnectShareAction'
description = _('Send books via email or the web. Also connect to'
' folders on your computer as if they are devices')
class ActionHelp(InterfaceActionBase):
name = 'Help'
- actual_plugin = 'calibre.gui2.actions.help:HelpAction'
+ actual_plugin = 'ebook_converter.gui2.actions.help:HelpAction'
description = _('Browse the calibre User Manual')
class ActionPreferences(InterfaceActionBase):
name = 'Preferences'
- actual_plugin = 'calibre.gui2.actions.preferences:PreferencesAction'
+ actual_plugin = 'ebook_converter.gui2.actions.preferences:PreferencesAction'
description = _('Customize calibre')
class ActionSimilarBooks(InterfaceActionBase):
name = 'Similar Books'
- actual_plugin = 'calibre.gui2.actions.similar_books:SimilarBooksAction'
+ actual_plugin = 'ebook_converter.gui2.actions.similar_books:SimilarBooksAction'
description = _('Easily find books similar to the currently selected one')
class ActionChooseLibrary(InterfaceActionBase):
name = 'Choose Library'
- actual_plugin = 'calibre.gui2.actions.choose_library:ChooseLibraryAction'
+ actual_plugin = 'ebook_converter.gui2.actions.choose_library:ChooseLibraryAction'
description = _('Switch between different calibre libraries and perform'
' maintenance on them')
class ActionAddToLibrary(InterfaceActionBase):
name = 'Add To Library'
- actual_plugin = 'calibre.gui2.actions.add_to_library:AddToLibraryAction'
+ actual_plugin = 'ebook_converter.gui2.actions.add_to_library:AddToLibraryAction'
description = _('Copy books from the device to your calibre library')
class ActionEditCollections(InterfaceActionBase):
name = 'Edit Collections'
- actual_plugin = 'calibre.gui2.actions.edit_collections:EditCollectionsAction'
+ actual_plugin = 'ebook_converter.gui2.actions.edit_collections:EditCollectionsAction'
description = _('Edit the collections in which books are placed on your device')
class ActionMatchBooks(InterfaceActionBase):
name = 'Match Books'
- actual_plugin = 'calibre.gui2.actions.match_books:MatchBookAction'
+ actual_plugin = 'ebook_converter.gui2.actions.match_books:MatchBookAction'
description = _('Match book on the devices to books in the library')
class ActionCopyToLibrary(InterfaceActionBase):
name = 'Copy To Library'
- actual_plugin = 'calibre.gui2.actions.copy_to_library:CopyToLibraryAction'
+ actual_plugin = 'ebook_converter.gui2.actions.copy_to_library:CopyToLibraryAction'
description = _('Copy a book from one calibre library to another')
class ActionTweakEpub(InterfaceActionBase):
name = 'Tweak ePub'
- actual_plugin = 'calibre.gui2.actions.tweak_epub:TweakEpubAction'
+ actual_plugin = 'ebook_converter.gui2.actions.tweak_epub:TweakEpubAction'
description = _('Edit e-books in the EPUB or AZW3 formats')
class ActionUnpackBook(InterfaceActionBase):
name = 'Unpack Book'
- actual_plugin = 'calibre.gui2.actions.unpack_book:UnpackBookAction'
+ actual_plugin = 'ebook_converter.gui2.actions.unpack_book:UnpackBookAction'
description = _('Make small changes to EPUB or HTMLZ files in your calibre library')
class ActionNextMatch(InterfaceActionBase):
name = 'Next Match'
- actual_plugin = 'calibre.gui2.actions.next_match:NextMatchAction'
+ actual_plugin = 'ebook_converter.gui2.actions.next_match:NextMatchAction'
description = _('Find the next or previous match when searching in '
'your calibre library in highlight mode')
class ActionPickRandom(InterfaceActionBase):
name = 'Pick Random Book'
- actual_plugin = 'calibre.gui2.actions.random:PickRandomAction'
+ actual_plugin = 'ebook_converter.gui2.actions.random:PickRandomAction'
description = _('Choose a random book from your calibre library')
class ActionSortBy(InterfaceActionBase):
name = 'Sort By'
- actual_plugin = 'calibre.gui2.actions.sort:SortByAction'
+ actual_plugin = 'ebook_converter.gui2.actions.sort:SortByAction'
description = _('Sort the list of books')
class ActionMarkBooks(InterfaceActionBase):
name = 'Mark Books'
- actual_plugin = 'calibre.gui2.actions.mark_books:MarkBooksAction'
+ actual_plugin = 'ebook_converter.gui2.actions.mark_books:MarkBooksAction'
description = _('Temporarily mark books')
class ActionVirtualLibrary(InterfaceActionBase):
name = 'Virtual Library'
- actual_plugin = 'calibre.gui2.actions.virtual_library:VirtualLibraryAction'
+ actual_plugin = 'ebook_converter.gui2.actions.virtual_library:VirtualLibraryAction'
description = _('Change the current Virtual library')
class ActionStore(InterfaceActionBase):
name = 'Store'
author = 'John Schember'
- actual_plugin = 'calibre.gui2.actions.store:StoreAction'
+ actual_plugin = 'ebook_converter.gui2.actions.store:StoreAction'
description = _('Search for books from different book sellers')
def customization_help(self, gui=False):
return 'Customize the behavior of the store search.'
def config_widget(self):
- from calibre.gui2.store.config.store import config_widget as get_cw
+ from ebook_converter.gui2.store.config.store import config_widget as get_cw
return get_cw()
def save_settings(self, config_widget):
- from calibre.gui2.store.config.store import save_settings as save
+ from ebook_converter.gui2.store.config.store import save_settings as save
save(config_widget)
class ActionPluginUpdater(InterfaceActionBase):
name = 'Plugin Updater'
author = 'Grant Drake'
- description = _('Get new calibre plugins or update your existing ones')
+ description = _('Get new ebook_converter plugins or update your existing ones')
actual_plugin = 'calibre.gui2.actions.plugin_updates:PluginUpdaterAction'
@@ -1110,7 +1110,7 @@ class LookAndFeel(PreferencesPlugin):
gui_category = _('Interface')
category_order = 1
name_order = 1
- config_widget = 'calibre.gui2.preferences.look_feel'
+ config_widget = 'ebook_converter.gui2.preferences.look_feel'
description = _('Adjust the look and feel of the calibre interface'
' to suit your tastes')
@@ -1123,7 +1123,7 @@ class Behavior(PreferencesPlugin):
gui_category = _('Interface')
category_order = 1
name_order = 2
- config_widget = 'calibre.gui2.preferences.behavior'
+ config_widget = 'ebook_converter.gui2.preferences.behavior'
description = _('Change the way calibre behaves')
@@ -1135,7 +1135,7 @@ class Columns(PreferencesPlugin):
gui_category = _('Interface')
category_order = 1
name_order = 3
- config_widget = 'calibre.gui2.preferences.columns'
+ config_widget = 'ebook_converter.gui2.preferences.columns'
description = _('Add/remove your own columns to the calibre book list')
@@ -1147,7 +1147,7 @@ class Toolbar(PreferencesPlugin):
gui_category = _('Interface')
category_order = 1
name_order = 4
- config_widget = 'calibre.gui2.preferences.toolbar'
+ config_widget = 'ebook_converter.gui2.preferences.toolbar'
description = _('Customize the toolbars and context menus, changing which'
' actions are available in each')
@@ -1160,7 +1160,7 @@ class Search(PreferencesPlugin):
gui_category = _('Interface')
category_order = 1
name_order = 5
- config_widget = 'calibre.gui2.preferences.search'
+ config_widget = 'ebook_converter.gui2.preferences.search'
description = _('Customize the way searching for books works in calibre')
@@ -1172,12 +1172,12 @@ class InputOptions(PreferencesPlugin):
gui_category = _('Conversion')
category_order = 2
name_order = 1
- config_widget = 'calibre.gui2.preferences.conversion:InputOptions'
+ config_widget = 'ebook_converter.gui2.preferences.conversion:InputOptions'
description = _('Set conversion options specific to each input format')
def create_widget(self, *args, **kwargs):
# The DOC Input plugin tries to override this
- self.config_widget = 'calibre.gui2.preferences.conversion:InputOptions'
+ self.config_widget = 'ebook_converter.gui2.preferences.conversion:InputOptions'
return PreferencesPlugin.create_widget(self, *args, **kwargs)
@@ -1189,7 +1189,7 @@ class CommonOptions(PreferencesPlugin):
gui_category = _('Conversion')
category_order = 2
name_order = 2
- config_widget = 'calibre.gui2.preferences.conversion:CommonOptions'
+ config_widget = 'ebook_converter.gui2.preferences.conversion:CommonOptions'
description = _('Set conversion options common to all formats')
@@ -1201,7 +1201,7 @@ class OutputOptions(PreferencesPlugin):
gui_category = _('Conversion')
category_order = 2
name_order = 3
- config_widget = 'calibre.gui2.preferences.conversion:OutputOptions'
+ config_widget = 'ebook_converter.gui2.preferences.conversion:OutputOptions'
description = _('Set conversion options specific to each output format')
@@ -1213,7 +1213,7 @@ class Adding(PreferencesPlugin):
gui_category = _('Import/export')
category_order = 3
name_order = 1
- config_widget = 'calibre.gui2.preferences.adding'
+ config_widget = 'ebook_converter.gui2.preferences.adding'
description = _('Control how calibre reads metadata from files when '
'adding books')
@@ -1226,7 +1226,7 @@ class Saving(PreferencesPlugin):
gui_category = _('Import/export')
category_order = 3
name_order = 2
- config_widget = 'calibre.gui2.preferences.saving'
+ config_widget = 'ebook_converter.gui2.preferences.saving'
description = _('Control how calibre exports files from its database '
'to disk when using Save to disk')
@@ -1239,7 +1239,7 @@ class Sending(PreferencesPlugin):
gui_category = _('Import/export')
category_order = 3
name_order = 3
- config_widget = 'calibre.gui2.preferences.sending'
+ config_widget = 'ebook_converter.gui2.preferences.sending'
description = _('Control how calibre transfers files to your '
'e-book reader')
@@ -1252,7 +1252,7 @@ class Plugboard(PreferencesPlugin):
gui_category = _('Import/export')
category_order = 3
name_order = 4
- config_widget = 'calibre.gui2.preferences.plugboard'
+ config_widget = 'ebook_converter.gui2.preferences.plugboard'
description = _('Change metadata fields before saving/sending')
@@ -1264,7 +1264,7 @@ class TemplateFunctions(PreferencesPlugin):
gui_category = _('Advanced')
category_order = 5
name_order = 5
- config_widget = 'calibre.gui2.preferences.template_functions'
+ config_widget = 'ebook_converter.gui2.preferences.template_functions'
description = _('Create your own template functions')
@@ -1276,7 +1276,7 @@ class Email(PreferencesPlugin):
gui_category = _('Sharing')
category_order = 4
name_order = 1
- config_widget = 'calibre.gui2.preferences.emailp'
+ config_widget = 'ebook_converter.gui2.preferences.emailp'
description = _('Setup sharing of books via email. Can be used '
'for automatic sending of downloaded news to your devices')
@@ -1289,7 +1289,7 @@ class Server(PreferencesPlugin):
gui_category = _('Sharing')
category_order = 4
name_order = 2
- config_widget = 'calibre.gui2.preferences.server'
+ config_widget = 'ebook_converter.gui2.preferences.server'
description = _('Setup the calibre Content server which will '
'give you access to your calibre library from anywhere, '
'on any device, over the internet')
@@ -1303,7 +1303,7 @@ class MetadataSources(PreferencesPlugin):
gui_category = _('Sharing')
category_order = 4
name_order = 3
- config_widget = 'calibre.gui2.preferences.metadata_sources'
+ config_widget = 'ebook_converter.gui2.preferences.metadata_sources'
description = _('Control how calibre downloads e-book metadata from the net')
@@ -1315,7 +1315,7 @@ class IgnoredDevices(PreferencesPlugin):
gui_category = _('Sharing')
category_order = 4
name_order = 4
- config_widget = 'calibre.gui2.preferences.ignored_devices'
+ config_widget = 'ebook_converter.gui2.preferences.ignored_devices'
description = _('Control which devices calibre will ignore when they are connected '
'to the computer.')
@@ -1328,7 +1328,7 @@ class Plugins(PreferencesPlugin):
gui_category = _('Advanced')
category_order = 5
name_order = 1
- config_widget = 'calibre.gui2.preferences.plugins'
+ config_widget = 'ebook_converter.gui2.preferences.plugins'
description = _('Add/remove/customize various bits of calibre '
'functionality')
@@ -1341,7 +1341,7 @@ class Tweaks(PreferencesPlugin):
gui_category = _('Advanced')
category_order = 5
name_order = 2
- config_widget = 'calibre.gui2.preferences.tweaks'
+ config_widget = 'ebook_converter.gui2.preferences.tweaks'
description = _('Fine tune how calibre behaves in various contexts')
@@ -1353,7 +1353,7 @@ class Keyboard(PreferencesPlugin):
gui_category = _('Advanced')
category_order = 5
name_order = 4
- config_widget = 'calibre.gui2.preferences.keyboard'
+ config_widget = 'ebook_converter.gui2.preferences.keyboard'
description = _('Customize the keyboard shortcuts used by calibre')
@@ -1365,7 +1365,7 @@ class Misc(PreferencesPlugin):
gui_category = _('Advanced')
category_order = 5
name_order = 3
- config_widget = 'calibre.gui2.preferences.misc'
+ config_widget = 'ebook_converter.gui2.preferences.misc'
description = _('Miscellaneous advanced configuration')
@@ -1382,7 +1382,7 @@ plugins += [LookAndFeel, Behavior, Columns, Toolbar, Search, InputOptions,
class StoreAmazonKindleStore(StoreBase):
name = 'Amazon Kindle'
description = 'Kindle books from Amazon.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_plugin:AmazonKindleStore'
headquarters = 'US'
formats = ['KINDLE']
@@ -1393,7 +1393,7 @@ class StoreAmazonAUKindleStore(StoreBase):
name = 'Amazon AU Kindle'
author = 'Kovid Goyal'
description = 'Kindle books from Amazon.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_au_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_au_plugin:AmazonKindleStore'
headquarters = 'AU'
formats = ['KINDLE']
@@ -1403,7 +1403,7 @@ class StoreAmazonCAKindleStore(StoreBase):
name = 'Amazon CA Kindle'
author = 'Kovid Goyal'
description = 'Kindle books from Amazon.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_ca_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_ca_plugin:AmazonKindleStore'
headquarters = 'CA'
formats = ['KINDLE']
@@ -1413,7 +1413,7 @@ class StoreAmazonINKindleStore(StoreBase):
name = 'Amazon IN Kindle'
author = 'Kovid Goyal'
description = 'Kindle books from Amazon.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_in_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_in_plugin:AmazonKindleStore'
headquarters = 'IN'
formats = ['KINDLE']
@@ -1423,7 +1423,7 @@ class StoreAmazonDEKindleStore(StoreBase):
name = 'Amazon DE Kindle'
author = 'Kovid Goyal'
description = 'Kindle Bücher von Amazon.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_de_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_de_plugin:AmazonKindleStore'
headquarters = 'DE'
formats = ['KINDLE']
@@ -1433,7 +1433,7 @@ class StoreAmazonFRKindleStore(StoreBase):
name = 'Amazon FR Kindle'
author = 'Kovid Goyal'
description = 'Tous les e-books Kindle'
- actual_plugin = 'calibre.gui2.store.stores.amazon_fr_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_fr_plugin:AmazonKindleStore'
headquarters = 'FR'
formats = ['KINDLE']
@@ -1443,7 +1443,7 @@ class StoreAmazonITKindleStore(StoreBase):
name = 'Amazon IT Kindle'
author = 'Kovid Goyal'
description = 'e-book Kindle a prezzi incredibili'
- actual_plugin = 'calibre.gui2.store.stores.amazon_it_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_it_plugin:AmazonKindleStore'
headquarters = 'IT'
formats = ['KINDLE']
@@ -1453,7 +1453,7 @@ class StoreAmazonESKindleStore(StoreBase):
name = 'Amazon ES Kindle'
author = 'Kovid Goyal'
description = 'e-book Kindle en España'
- actual_plugin = 'calibre.gui2.store.stores.amazon_es_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_es_plugin:AmazonKindleStore'
headquarters = 'ES'
formats = ['KINDLE']
@@ -1463,7 +1463,7 @@ class StoreAmazonUKKindleStore(StoreBase):
name = 'Amazon UK Kindle'
author = 'Kovid Goyal'
description = 'Kindle books from Amazon\'s UK web site. Also, includes French language e-books.'
- actual_plugin = 'calibre.gui2.store.stores.amazon_uk_plugin:AmazonKindleStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.amazon_uk_plugin:AmazonKindleStore'
headquarters = 'UK'
formats = ['KINDLE']
@@ -1472,7 +1472,7 @@ class StoreAmazonUKKindleStore(StoreBase):
class StoreArchiveOrgStore(StoreBase):
name = 'Archive.org'
description = 'An Internet library offering permanent access for researchers, historians, scholars, people with disabilities, and the general public to historical collections that exist in digital format.' # noqa
- actual_plugin = 'calibre.gui2.store.stores.archive_org_plugin:ArchiveOrgStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.archive_org_plugin:ArchiveOrgStore'
drm_free_only = True
headquarters = 'US'
@@ -1482,7 +1482,7 @@ class StoreArchiveOrgStore(StoreBase):
class StoreBubokPublishingStore(StoreBase):
name = 'Bubok Spain'
description = 'Bubok Publishing is a publisher, library and store of books of authors from all around the world. They have a big amount of books of a lot of topics' # noqa
- actual_plugin = 'calibre.gui2.store.stores.bubok_publishing_plugin:BubokPublishingStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.bubok_publishing_plugin:BubokPublishingStore'
drm_free_only = True
headquarters = 'ES'
@@ -1492,7 +1492,7 @@ class StoreBubokPublishingStore(StoreBase):
class StoreBubokPortugalStore(StoreBase):
name = 'Bubok Portugal'
description = 'Bubok Publishing Portugal is a publisher, library and store of books of authors from Portugal. They have a big amount of books of a lot of topics' # noqa
- actual_plugin = 'calibre.gui2.store.stores.bubok_portugal_plugin:BubokPortugalStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.bubok_portugal_plugin:BubokPortugalStore'
drm_free_only = True
headquarters = 'PT'
@@ -1502,7 +1502,7 @@ class StoreBubokPortugalStore(StoreBase):
class StoreBaenWebScriptionStore(StoreBase):
name = 'Baen Ebooks'
description = 'Sci-Fi & Fantasy brought to you by Jim Baen.'
- actual_plugin = 'calibre.gui2.store.stores.baen_webscription_plugin:BaenWebScriptionStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.baen_webscription_plugin:BaenWebScriptionStore'
drm_free_only = True
headquarters = 'US'
@@ -1512,7 +1512,7 @@ class StoreBaenWebScriptionStore(StoreBase):
class StoreBNStore(StoreBase):
name = 'Barnes and Noble'
description = 'The world\'s largest book seller. As the ultimate destination for book lovers, Barnes & Noble.com offers an incredible array of content.'
- actual_plugin = 'calibre.gui2.store.stores.bn_plugin:BNStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.bn_plugin:BNStore'
headquarters = 'US'
formats = ['NOOK']
@@ -1522,7 +1522,7 @@ class StoreBeamEBooksDEStore(StoreBase):
name = 'Beam EBooks DE'
author = 'Charles Haley'
description = 'Bei uns finden Sie: Tausende deutschsprachige e-books; Alle e-books ohne hartes DRM; PDF, ePub und Mobipocket Format; Sofortige Verfügbarkeit - 24 Stunden am Tag; Günstige Preise; e-books für viele Lesegeräte, PC,Mac und Smartphones; Viele Gratis e-books' # noqa
- actual_plugin = 'calibre.gui2.store.stores.beam_ebooks_de_plugin:BeamEBooksDEStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.beam_ebooks_de_plugin:BeamEBooksDEStore'
drm_free_only = True
headquarters = 'DE'
@@ -1533,7 +1533,7 @@ class StoreBiblioStore(StoreBase):
name = 'Библио.бг'
author = 'Alex Stanev'
description = 'Електронна книжарница за книги и списания във формати ePUB и PDF. Част от заглавията са с активна DRM защита.'
- actual_plugin = 'calibre.gui2.store.stores.biblio_plugin:BiblioStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.biblio_plugin:BiblioStore'
headquarters = 'BG'
formats = ['EPUB, PDF']
@@ -1543,7 +1543,7 @@ class StoreChitankaStore(StoreBase):
name = 'Моята библиотека'
author = 'Alex Stanev'
description = 'Независим сайт за DRM свободна литература на български език'
- actual_plugin = 'calibre.gui2.store.stores.chitanka_plugin:ChitankaStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.chitanka_plugin:ChitankaStore'
drm_free_only = True
headquarters = 'BG'
@@ -1553,7 +1553,7 @@ class StoreChitankaStore(StoreBase):
class StoreEbookNLStore(StoreBase):
name = 'eBook.nl'
description = 'De eBookwinkel van Nederland'
- actual_plugin = 'calibre.gui2.store.stores.ebook_nl_plugin:EBookNLStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.ebook_nl_plugin:EBookNLStore'
headquarters = 'NL'
formats = ['EPUB', 'PDF']
@@ -1564,7 +1564,7 @@ class StoreEbookpointStore(StoreBase):
name = 'Ebookpoint'
author = 'Tomasz Długosz'
description = 'E-booki wolne od DRM, 3 formaty w pakiecie, wysyłanie na Kindle'
- actual_plugin = 'calibre.gui2.store.stores.ebookpoint_plugin:EbookpointStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.ebookpoint_plugin:EbookpointStore'
drm_free_only = True
headquarters = 'PL'
@@ -1575,7 +1575,7 @@ class StoreEbookpointStore(StoreBase):
class StoreEbookscomStore(StoreBase):
name = 'eBooks.com'
description = 'Sells books in multiple electronic formats in all categories. Technical infrastructure is cutting edge, robust and scalable, with servers in the US and Europe.' # noqa
- actual_plugin = 'calibre.gui2.store.stores.ebooks_com_plugin:EbookscomStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.ebooks_com_plugin:EbookscomStore'
headquarters = 'US'
formats = ['EPUB', 'LIT', 'MOBI', 'PDF']
@@ -1585,7 +1585,7 @@ class StoreEbookscomStore(StoreBase):
class StoreEbooksGratuitsStore(StoreBase):
name = 'EbooksGratuits.com'
description = 'Ebooks Libres et Gratuits'
- actual_plugin = 'calibre.gui2.store.stores.ebooksgratuits_plugin:EbooksGratuitsStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.ebooksgratuits_plugin:EbooksGratuitsStore'
headquarters = 'FR'
formats = ['EPUB', 'MOBI', 'PDF', 'PDB']
@@ -1595,7 +1595,7 @@ class StoreEbooksGratuitsStore(StoreBase):
# name = 'ebookShoppe UK'
# author = 'Charles Haley'
# description = 'We made this website in an attempt to offer the widest range of UK eBooks possible across and as many formats as we could manage.'
-# actual_plugin = 'calibre.gui2.store.stores.ebookshoppe_uk_plugin:EBookShoppeUKStore'
+# actual_plugin = 'ebook_converter.gui2.store.stores.ebookshoppe_uk_plugin:EBookShoppeUKStore'
#
# headquarters = 'UK'
# formats = ['EPUB', 'PDF']
@@ -1606,7 +1606,7 @@ class StoreEKnigiStore(StoreBase):
name = 'еКниги'
author = 'Alex Stanev'
description = 'Онлайн книжарница за електронни книги и аудио риалити романи'
- actual_plugin = 'calibre.gui2.store.stores.eknigi_plugin:eKnigiStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.eknigi_plugin:eKnigiStore'
headquarters = 'BG'
formats = ['EPUB', 'PDF', 'HTML']
@@ -1617,7 +1617,7 @@ class StoreEmpikStore(StoreBase):
name = 'Empik'
author = 'Tomasz Długosz'
description = 'Empik to marka o unikalnym dziedzictwie i legendarne miejsce, dawne “okno na świat”. Jest obecna w polskim krajobrazie kulturalnym od 60 lat (wcześniej jako Kluby Międzynarodowej Prasy i Książki).' # noqa
- actual_plugin = 'calibre.gui2.store.stores.empik_plugin:EmpikStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.empik_plugin:EmpikStore'
headquarters = 'PL'
formats = ['EPUB', 'MOBI', 'PDF']
@@ -1627,7 +1627,7 @@ class StoreEmpikStore(StoreBase):
class StoreFeedbooksStore(StoreBase):
name = 'Feedbooks'
description = 'Feedbooks is a cloud publishing and distribution service, connected to a large ecosystem of reading systems and social networks. Provides a variety of genres from independent and classic books.' # noqa
- actual_plugin = 'calibre.gui2.store.stores.feedbooks_plugin:FeedbooksStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.feedbooks_plugin:FeedbooksStore'
headquarters = 'FR'
formats = ['EPUB', 'MOBI', 'PDF']
@@ -1636,7 +1636,7 @@ class StoreFeedbooksStore(StoreBase):
class StoreGoogleBooksStore(StoreBase):
name = 'Google Books'
description = 'Google Books'
- actual_plugin = 'calibre.gui2.store.stores.google_books_plugin:GoogleBooksStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.google_books_plugin:GoogleBooksStore'
headquarters = 'US'
formats = ['EPUB', 'PDF', 'TXT']
@@ -1645,7 +1645,7 @@ class StoreGoogleBooksStore(StoreBase):
class StoreGutenbergStore(StoreBase):
name = 'Project Gutenberg'
description = 'The first producer of free e-books. Free in the United States because their copyright has expired. They may not be free of copyright in other countries. Readers outside of the United States must check the copyright laws of their countries before downloading or redistributing our e-books.' # noqa
- actual_plugin = 'calibre.gui2.store.stores.gutenberg_plugin:GutenbergStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.gutenberg_plugin:GutenbergStore'
drm_free_only = True
headquarters = 'US'
@@ -1655,7 +1655,7 @@ class StoreGutenbergStore(StoreBase):
class StoreKoboStore(StoreBase):
name = 'Kobo'
description = 'With over 2.3 million e-books to browse we have engaged readers in over 200 countries in Kobo eReading. Our e-book listings include New York Times Bestsellers, award winners, classics and more!' # noqa
- actual_plugin = 'calibre.gui2.store.stores.kobo_plugin:KoboStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.kobo_plugin:KoboStore'
headquarters = 'CA'
formats = ['EPUB']
@@ -1666,7 +1666,7 @@ class StoreLegimiStore(StoreBase):
name = 'Legimi'
author = 'Tomasz Długosz'
description = 'E-booki w formacie EPUB, MOBI i PDF'
- actual_plugin = 'calibre.gui2.store.stores.legimi_plugin:LegimiStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.legimi_plugin:LegimiStore'
headquarters = 'PL'
formats = ['EPUB', 'PDF', 'MOBI']
@@ -1677,7 +1677,7 @@ class StoreLibreDEStore(StoreBase):
name = 'ebook.de'
author = 'Charles Haley'
description = 'All Ihre Bücher immer dabei. Suchen, finden, kaufen: so einfach wie nie. ebook.de war libre.de'
- actual_plugin = 'calibre.gui2.store.stores.libri_de_plugin:LibreDEStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.libri_de_plugin:LibreDEStore'
headquarters = 'DE'
formats = ['EPUB', 'PDF']
@@ -1687,7 +1687,7 @@ class StoreLibreDEStore(StoreBase):
class StoreLitResStore(StoreBase):
name = 'LitRes'
description = 'e-books from LitRes.ru'
- actual_plugin = 'calibre.gui2.store.stores.litres_plugin:LitResStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.litres_plugin:LitResStore'
author = 'Roman Mukhin'
drm_free_only = False
@@ -1699,7 +1699,7 @@ class StoreLitResStore(StoreBase):
class StoreManyBooksStore(StoreBase):
name = 'ManyBooks'
description = 'Public domain and creative commons works from many sources.'
- actual_plugin = 'calibre.gui2.store.stores.manybooks_plugin:ManyBooksStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.manybooks_plugin:ManyBooksStore'
drm_free_only = True
headquarters = 'US'
@@ -1710,7 +1710,7 @@ class StoreMillsBoonUKStore(StoreBase):
name = 'Mills and Boon UK'
author = 'Charles Haley'
description = '"Bring Romance to Life" "[A] hallmark for romantic fiction, recognised around the world."'
- actual_plugin = 'calibre.gui2.store.stores.mills_boon_uk_plugin:MillsBoonUKStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.mills_boon_uk_plugin:MillsBoonUKStore'
headquarters = 'UK'
formats = ['EPUB']
@@ -1720,7 +1720,7 @@ class StoreMillsBoonUKStore(StoreBase):
class StoreMobileReadStore(StoreBase):
name = 'MobileRead'
description = 'E-books handcrafted with the utmost care.'
- actual_plugin = 'calibre.gui2.store.stores.mobileread.mobileread_plugin:MobileReadStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.mobileread.mobileread_plugin:MobileReadStore'
drm_free_only = True
headquarters = 'CH'
@@ -1731,7 +1731,7 @@ class StoreNextoStore(StoreBase):
name = 'Nexto'
author = 'Tomasz Długosz'
description = 'Największy w Polsce sklep internetowy z audiobookami mp3, ebookami pdf oraz prasą do pobrania on-line.'
- actual_plugin = 'calibre.gui2.store.stores.nexto_plugin:NextoStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.nexto_plugin:NextoStore'
headquarters = 'PL'
formats = ['EPUB', 'MOBI', 'PDF']
@@ -1741,7 +1741,7 @@ class StoreNextoStore(StoreBase):
class StoreOzonRUStore(StoreBase):
name = 'OZON.ru'
description = 'e-books from OZON.ru'
- actual_plugin = 'calibre.gui2.store.stores.ozon_ru_plugin:OzonRUStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.ozon_ru_plugin:OzonRUStore'
author = 'Roman Mukhin'
drm_free_only = True
@@ -1753,7 +1753,7 @@ class StoreOzonRUStore(StoreBase):
class StorePragmaticBookshelfStore(StoreBase):
name = 'Pragmatic Bookshelf'
description = 'The Pragmatic Bookshelf\'s collection of programming and tech books avaliable as e-books.'
- actual_plugin = 'calibre.gui2.store.stores.pragmatic_bookshelf_plugin:PragmaticBookshelfStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.pragmatic_bookshelf_plugin:PragmaticBookshelfStore'
drm_free_only = True
headquarters = 'US'
@@ -1763,7 +1763,7 @@ class StorePragmaticBookshelfStore(StoreBase):
class StorePublioStore(StoreBase):
name = 'Publio'
description = 'Publio.pl to księgarnia internetowa, w której mogą Państwo nabyć e-booki i audiobooki.'
- actual_plugin = 'calibre.gui2.store.stores.publio_plugin:PublioStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.publio_plugin:PublioStore'
author = 'Tomasz Długosz'
headquarters = 'PL'
@@ -1774,7 +1774,7 @@ class StorePublioStore(StoreBase):
class StoreRW2010Store(StoreBase):
name = 'RW2010'
description = 'Polski serwis self-publishingowy. Pliki PDF, EPUB i MOBI.'
- actual_plugin = 'calibre.gui2.store.stores.rw2010_plugin:RW2010Store'
+ actual_plugin = 'ebook_converter.gui2.store.stores.rw2010_plugin:RW2010Store'
author = 'Tomasz Długosz'
drm_free_only = True
@@ -1785,7 +1785,7 @@ class StoreRW2010Store(StoreBase):
class StoreSmashwordsStore(StoreBase):
name = 'Smashwords'
description = 'An e-book publishing and distribution platform for e-book authors, publishers and readers. Covers many genres and formats.'
- actual_plugin = 'calibre.gui2.store.stores.smashwords_plugin:SmashwordsStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.smashwords_plugin:SmashwordsStore'
drm_free_only = True
headquarters = 'US'
@@ -1797,7 +1797,7 @@ class StoreSwiatEbookowStore(StoreBase):
name = 'Świat Ebooków'
author = 'Tomasz Długosz'
description = 'Ebooki maje tę zaletę, że są zawsze i wszędzie tam, gdzie tylko nas dopadnie ochota na czytanie.'
- actual_plugin = 'calibre.gui2.store.stores.swiatebookow_plugin:SwiatEbookowStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.swiatebookow_plugin:SwiatEbookowStore'
drm_free_only = True
headquarters = 'PL'
@@ -1809,7 +1809,7 @@ class StoreVirtualoStore(StoreBase):
name = 'Virtualo'
author = 'Tomasz Długosz'
description = 'Księgarnia internetowa, która oferuje bezpieczny i szeroki dostęp do książek w formie cyfrowej.'
- actual_plugin = 'calibre.gui2.store.stores.virtualo_plugin:VirtualoStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.virtualo_plugin:VirtualoStore'
headquarters = 'PL'
formats = ['EPUB', 'MOBI', 'PDF']
@@ -1819,7 +1819,7 @@ class StoreVirtualoStore(StoreBase):
class StoreWeightlessBooksStore(StoreBase):
name = 'Weightless Books'
description = 'An independent DRM-free e-book site devoted to e-books of all sorts.'
- actual_plugin = 'calibre.gui2.store.stores.weightless_books_plugin:WeightlessBooksStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.weightless_books_plugin:WeightlessBooksStore'
drm_free_only = True
headquarters = 'US'
@@ -1830,7 +1830,7 @@ class StoreWHSmithUKStore(StoreBase):
name = 'WH Smith UK'
author = 'Charles Haley'
description = u"Shop for savings on Books, discounted Magazine subscriptions and great prices on Stationery, Toys & Games"
- actual_plugin = 'calibre.gui2.store.stores.whsmith_uk_plugin:WHSmithUKStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.whsmith_uk_plugin:WHSmithUKStore'
headquarters = 'UK'
formats = ['EPUB', 'PDF']
@@ -1840,7 +1840,7 @@ class StoreWolneLekturyStore(StoreBase):
name = 'Wolne Lektury'
author = 'Tomasz Długosz'
description = 'Wolne Lektury to biblioteka internetowa czynna 24 godziny na dobę, 365 dni w roku, której zasoby dostępne są całkowicie za darmo. Wszystkie dzieła są odpowiednio opracowane - opatrzone przypisami, motywami i udostępnione w kilku formatach - HTML, TXT, PDF, EPUB, MOBI, FB2.' # noqa
- actual_plugin = 'calibre.gui2.store.stores.wolnelektury_plugin:WolneLekturyStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.wolnelektury_plugin:WolneLekturyStore'
headquarters = 'PL'
formats = ['EPUB', 'MOBI', 'PDF', 'TXT', 'FB2']
@@ -1850,7 +1850,7 @@ class StoreWoblinkStore(StoreBase):
name = 'Woblink'
author = 'Tomasz Długosz'
description = 'Czytanie zdarza się wszędzie!'
- actual_plugin = 'calibre.gui2.store.stores.woblink_plugin:WoblinkStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.woblink_plugin:WoblinkStore'
headquarters = 'PL'
formats = ['EPUB', 'MOBI', 'PDF', 'WOBLINK']
@@ -1860,7 +1860,7 @@ class StoreWoblinkStore(StoreBase):
class XinXiiStore(StoreBase):
name = 'XinXii'
description = ''
- actual_plugin = 'calibre.gui2.store.stores.xinxii_plugin:XinXiiStore'
+ actual_plugin = 'ebook_converter.gui2.store.stores.xinxii_plugin:XinXiiStore'
headquarters = 'DE'
formats = ['EPUB', 'PDF']
@@ -1926,7 +1926,7 @@ if __name__ == '__main__':
import init_calibre # noqa
def doit():
- import calibre.customize.builtins as b # noqa
+ import ebook_converter.customize.builtins as b # noqa
def show_stats():
from pstats import Stats
@@ -1948,22 +1948,22 @@ if __name__ == '__main__':
from __future__ import print_function
import time, sys, init_calibre
st = time.time()
- import calibre.customize.builtins
+ import ebook_converter.customize.builtins
t = time.time() - st
ret = 0
- for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
- 'calibre.utils.terminal', 'calibre.utils.img', 'PIL', 'Image',
+ for x in ('lxml', 'ebook_converter.ebooks.BeautifulSoup', 'uuid',
+ 'ebook_converter.utils.terminal', 'ebook_converter.utils.img', 'PIL', 'Image',
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib',
- 'calibre.utils.date', 'calibre.utils.config', 'platform',
- 'calibre.utils.zipfile', 'calibre.utils.formatter',
+ 'ebook_converter.utils.date', 'ebook_converter.utils.config', 'platform',
+ 'ebook_converter.utils.zipfile', 'ebook_converter.utils.formatter',
):
if x in sys.modules:
ret = 1
print (x, 'has been loaded by a plugin')
if ret:
print ('\\nA good way to track down what is loading something is to run'
- ' python -c "import init_calibre; import calibre.customize.builtins"')
+ ' python -c "import init_calibre; import ebook_converter.customize.builtins"')
print()
print ('Time taken to import all plugins: %.2f'%t)
sys.exit(ret)
diff --git a/ebook_converter/customize/conversion.py b/ebook_converter/customize/conversion.py
index ba8112f..2e5d96d 100644
--- a/ebook_converter/customize/conversion.py
+++ b/ebook_converter/customize/conversion.py
@@ -5,9 +5,9 @@ Defines the plugin system for conversions.
'''
import re, os, shutil, numbers
-from calibre import CurrentDir
-from calibre.customize import Plugin
-from polyglot.builtins import unicode_type
+from ebook_converter import CurrentDir
+from ebook_converter.customize import Plugin
+from ebook_converter.polyglot.builtins import unicode_type
class ConversionOption(object):
@@ -106,7 +106,7 @@ def gui_configuration_widget(name, parent, get_option_by_name,
if for_output:
try:
output_widget = importlib.import_module(
- 'calibre.gui2.convert.'+name)
+ 'ebook_converter.gui2.convert.'+name)
pw = output_widget.PluginWidget
pw.ICON = I('back.png')
pw.HELP = _('Options specific to the output format.')
@@ -116,7 +116,7 @@ def gui_configuration_widget(name, parent, get_option_by_name,
else:
try:
input_widget = importlib.import_module(
- 'calibre.gui2.convert.'+name)
+ 'ebook_converter.gui2.convert.'+name)
pw = input_widget.PluginWidget
pw.ICON = I('forward.png')
pw.HELP = _('Options specific to the input format.')
diff --git a/ebook_converter/customize/profiles.py b/ebook_converter/customize/profiles.py
index 0bc7892..3434a97 100644
--- a/ebook_converter/customize/profiles.py
+++ b/ebook_converter/customize/profiles.py
@@ -4,8 +4,8 @@ __license__ = 'GPL 3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre.customize import Plugin as _Plugin
-from polyglot.builtins import zip
+from ebook_converter.customize import Plugin as _Plugin
+from ebook_converter.polyglot.builtins import zip
FONT_SIZES = [('xx-small', 1),
('x-small', None),
diff --git a/ebook_converter/customize/ui.py b/ebook_converter/customize/ui.py
index 53cdfd1..416aa04 100644
--- a/ebook_converter/customize/ui.py
+++ b/ebook_converter/customize/ui.py
@@ -6,23 +6,23 @@ import os, shutil, traceback, functools, sys
from collections import defaultdict
from itertools import chain
-from calibre.customize import (CatalogPlugin, FileTypePlugin, PluginNotFound,
+from ebook_converter.customize import (CatalogPlugin, FileTypePlugin, PluginNotFound,
MetadataReaderPlugin, MetadataWriterPlugin,
InterfaceActionBase as InterfaceAction,
PreferencesPlugin, platform, InvalidPlugin,
StoreBase as Store, EditBookToolPlugin,
LibraryClosedPlugin)
-from calibre.customize.conversion import InputFormatPlugin, OutputFormatPlugin
-from calibre.customize.zipplugin import loader
-from calibre.customize.profiles import InputProfile, OutputProfile
-from calibre.customize.builtins import plugins as builtin_plugins
-from calibre.devices.interface import DevicePlugin
-from calibre.ebooks.metadata import MetaInformation
-from calibre.utils.config import (make_config_dir, Config, ConfigProxy,
+from ebook_converter.customize.conversion import InputFormatPlugin, OutputFormatPlugin
+from ebook_converter.customize.zipplugin import loader
+from ebook_converter.customize.profiles import InputProfile, OutputProfile
+from ebook_converter.customize.builtins import plugins as builtin_plugins
+# from ebook_converter.devices.interface import DevicePlugin
+from ebook_converter.ebooks.metadata import MetaInformation
+from ebook_converter.utils.config import (make_config_dir, Config, ConfigProxy,
plugin_dir, OptionParser)
-from calibre.ebooks.metadata.sources.base import Source
-from calibre.constants import DEBUG, numeric_version
-from polyglot.builtins import iteritems, itervalues, unicode_type
+# from ebook_converter.ebooks.metadata.sources.base import Source
+from ebook_converter.constants import DEBUG, numeric_version
+from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type
builtin_names = frozenset(p.name for p in builtin_plugins)
BLACKLISTED_PLUGINS = frozenset({'Marvin XD', 'iOS reader applications'})
@@ -448,7 +448,7 @@ def set_file_type_metadata(stream, mi, ftype, report_error=None):
break
except:
if report_error is None:
- from calibre import prints
+ from ebook_converter import prints
prints('Failed to set metadata for the', ftype.upper(), 'format of:', getattr(mi, 'title', ''), file=sys.stderr)
traceback.print_exc()
else:
@@ -737,9 +737,9 @@ def initialized_plugins():
def build_plugin(path):
- from calibre import prints
- from calibre.ptempfile import PersistentTemporaryFile
- from calibre.utils.zipfile import ZipFile, ZIP_STORED
+ from ebook_converter import prints
+ from ebook_converter.ptempfile import PersistentTemporaryFile
+ from ebook_converter.utils.zipfile import ZipFile, ZIP_STORED
path = unicode_type(path)
names = frozenset(os.listdir(path))
if '__init__.py' not in names:
diff --git a/ebook_converter/customize/zipplugin.py b/ebook_converter/customize/zipplugin.py
index 1ed5020..3c39329 100644
--- a/ebook_converter/customize/zipplugin.py
+++ b/ebook_converter/customize/zipplugin.py
@@ -10,11 +10,11 @@ import os, zipfile, posixpath, importlib, threading, re, imp, sys
from collections import OrderedDict
from functools import partial
-from calibre import as_unicode
-from calibre.constants import ispy3
-from calibre.customize import (Plugin, numeric_version, platform,
+from ebook_converter import as_unicode
+from ebook_converter.constants import ispy3
+from ebook_converter.customize import (Plugin, numeric_version, platform,
InvalidPlugin, PluginNotFound)
-from polyglot.builtins import (itervalues, map, string_or_bytes,
+from ebook_converter.polyglot.builtins import (itervalues, map, string_or_bytes,
unicode_type, reload)
# PEP 302 based plugin loading mechanism, works around the bug in zipimport in
@@ -94,7 +94,7 @@ def load_translations(namespace, zfp):
if trans is None:
return
if trans is null:
- from calibre.utils.localization import get_lang
+ from ebook_converter.utils.localization import get_lang
lang = get_lang()
if not lang or lang == 'en': # performance optimization
_translations_cache[zfp] = None
@@ -303,8 +303,8 @@ sys.meta_path.insert(0, loader)
if __name__ == '__main__':
from tempfile import NamedTemporaryFile
- from calibre.customize.ui import add_plugin
- from calibre import CurrentDir
+ from ebook_converter.customize.ui import add_plugin
+ from ebook_converter import CurrentDir
path = sys.argv[-1]
with NamedTemporaryFile(suffix='.zip') as f:
with zipfile.ZipFile(f, 'w') as zf:
diff --git a/ebook_converter/devices/__init__.py b/ebook_converter/devices/__init__.py
index a32fd45..e69de29 100644
--- a/ebook_converter/devices/__init__.py
+++ b/ebook_converter/devices/__init__.py
@@ -1,216 +0,0 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-__license__ = 'GPL v3'
-__copyright__ = '2008, Kovid Goyal '
-
-'''
-Device drivers.
-'''
-
-import sys, time, pprint
-from functools import partial
-from polyglot.builtins import zip, unicode_type
-
-DAY_MAP = dict(Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6)
-MONTH_MAP = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12)
-INVERSE_DAY_MAP = dict(zip(DAY_MAP.values(), DAY_MAP.keys()))
-INVERSE_MONTH_MAP = dict(zip(MONTH_MAP.values(), MONTH_MAP.keys()))
-
-
-def strptime(src):
- src = src.strip()
- src = src.split()
- src[0] = unicode_type(DAY_MAP[src[0][:-1]])+','
- src[2] = unicode_type(MONTH_MAP[src[2]])
- return time.strptime(' '.join(src), '%w, %d %m %Y %H:%M:%S %Z')
-
-
-def strftime(epoch, zone=time.gmtime):
- src = time.strftime("%w, %d %m %Y %H:%M:%S GMT", zone(epoch)).split()
- src[0] = INVERSE_DAY_MAP[int(src[0][:-1])]+','
- src[2] = INVERSE_MONTH_MAP[int(src[2])]
- return ' '.join(src)
-
-
-def get_connected_device():
- from calibre.customize.ui import device_plugins
- from calibre.devices.scanner import DeviceScanner
- dev = None
- scanner = DeviceScanner()
- scanner.scan()
- connected_devices = []
- for d in device_plugins():
- ok, det = scanner.is_device_connected(d)
- if ok:
- dev = d
- dev.reset(log_packets=False, detected_device=det)
- connected_devices.append((det, dev))
-
- if dev is None:
- print('Unable to find a connected ebook reader.', file=sys.stderr)
- return
-
- for det, d in connected_devices:
- try:
- d.open(det, None)
- except:
- continue
- else:
- dev = d
- break
- return dev
-
-
-def debug(ioreg_to_tmp=False, buf=None, plugins=None,
- disabled_plugins=None):
- '''
- If plugins is None, then this method calls startup and shutdown on the
- device plugins. So if you are using it in a context where startup could
- already have been called (for example in the main GUI), pass in the list of
- device plugins as the plugins parameter.
- '''
- import textwrap
- from calibre.customize.ui import device_plugins, disabled_device_plugins
- from calibre.debug import print_basic_debug_info
- from calibre.devices.scanner import DeviceScanner
- from calibre.constants import iswindows, isosx
- from calibre import prints
- from polyglot.io import PolyglotBytesIO
- oldo, olde = sys.stdout, sys.stderr
-
- if buf is None:
- buf = PolyglotBytesIO()
- sys.stdout = sys.stderr = buf
- out = partial(prints, file=buf)
-
- devplugins = device_plugins() if plugins is None else plugins
- devplugins = list(sorted(devplugins, key=lambda x: x.__class__.__name__))
- if plugins is None:
- for d in devplugins:
- try:
- d.startup()
- except:
- out('Startup failed for device plugin: %s'%d)
-
- if disabled_plugins is None:
- disabled_plugins = list(disabled_device_plugins())
-
- try:
- print_basic_debug_info(out=buf)
- s = DeviceScanner()
- s.scan()
- devices = (s.devices)
- if not iswindows:
- devices = [list(x) for x in devices]
- for d in devices:
- for i in range(3):
- d[i] = hex(d[i])
- out('USB devices on system:')
- out(pprint.pformat(devices))
-
- ioreg = None
- if isosx:
- from calibre.devices.usbms.device import Device
- mount = '\n'.join(repr(x) for x in Device.osx_run_mount().splitlines())
- drives = pprint.pformat(Device.osx_get_usb_drives())
- ioreg = 'Output from mount:\n'+mount+'\n\n'
- ioreg += 'Output from osx_get_usb_drives:\n'+drives+'\n\n'
- ioreg += Device.run_ioreg()
- connected_devices = []
- if disabled_plugins:
- out('\nDisabled plugins:', textwrap.fill(' '.join([x.__class__.__name__ for x in
- disabled_plugins])))
- out(' ')
- else:
- out('\nNo disabled plugins')
- found_dev = False
- for dev in devplugins:
- if not dev.MANAGES_DEVICE_PRESENCE:
- continue
- out('Looking for devices of type:', dev.__class__.__name__)
- if dev.debug_managed_device_detection(s.devices, buf):
- found_dev = True
- break
- out(' ')
-
- if not found_dev:
- out('Looking for devices...')
- for dev in devplugins:
- if dev.MANAGES_DEVICE_PRESENCE:
- continue
- connected, det = s.is_device_connected(dev, debug=True)
- if connected:
- out('\t\tDetected possible device', dev.__class__.__name__)
- connected_devices.append((dev, det))
-
- out(' ')
- errors = {}
- success = False
- out('Devices possibly connected:', end=' ')
- for dev, det in connected_devices:
- out(dev.name, end=', ')
- if not connected_devices:
- out('None', end='')
- out(' ')
- for dev, det in connected_devices:
- out('Trying to open', dev.name, '...', end=' ')
- dev.do_device_debug = True
- try:
- dev.reset(detected_device=det)
- dev.open(det, None)
- out('OK')
- except:
- import traceback
- errors[dev] = traceback.format_exc()
- out('failed')
- continue
- dev.do_device_debug = False
- success = True
- if hasattr(dev, '_main_prefix'):
- out('Main memory:', repr(dev._main_prefix))
- out('Total space:', dev.total_space())
- break
- if not success and errors:
- out('Opening of the following devices failed')
- for dev,msg in errors.items():
- out(dev)
- out(msg)
- out(' ')
-
- if ioreg is not None:
- ioreg = 'IOREG Output\n'+ioreg
- out(' ')
- if ioreg_to_tmp:
- lopen('/tmp/ioreg.txt', 'wb').write(ioreg)
- out('Dont forget to send the contents of /tmp/ioreg.txt')
- out('You can open it with the command: open /tmp/ioreg.txt')
- else:
- out(ioreg)
-
- if hasattr(buf, 'getvalue'):
- return buf.getvalue().decode('utf-8', 'replace')
- finally:
- sys.stdout = oldo
- sys.stderr = olde
- if plugins is None:
- for d in devplugins:
- try:
- d.shutdown()
- except:
- pass
-
-
-def device_info(ioreg_to_tmp=False, buf=None):
- from calibre.devices.scanner import DeviceScanner
-
- res = {}
- res['device_set'] = device_set = set()
- res['device_details'] = device_details = {}
-
- s = DeviceScanner()
- s.scan()
- devices = s.devices
- devices = [tuple(x) for x in devices]
- for dev in devices:
- device_set.add(dev)
- device_details[dev] = dev[0:3]
- return res
diff --git a/ebook_converter/devices/interface.py b/ebook_converter/devices/interface.py
index b74e255..312249b 100644
--- a/ebook_converter/devices/interface.py
+++ b/ebook_converter/devices/interface.py
@@ -5,9 +5,9 @@ __copyright__ = '2008, Kovid Goyal '
import os
from collections import namedtuple
-from calibre import prints
-from calibre.constants import iswindows
-from calibre.customize import Plugin
+from ebook_converter import prints
+from ebook_converter.constants import iswindows
+from ebook_converter.customize import Plugin
class DevicePlugin(Plugin):
diff --git a/ebook_converter/ebooks/BeautifulSoup.py b/ebook_converter/ebooks/BeautifulSoup.py
index 76d8683..35b0096 100644
--- a/ebook_converter/ebooks/BeautifulSoup.py
+++ b/ebook_converter/ebooks/BeautifulSoup.py
@@ -10,12 +10,12 @@ from bs4 import ( # noqa
SoupStrainer, Tag, __version__
)
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
def parse_html(markup):
- from calibre.ebooks.chardet import strip_encoding_declarations, xml_to_unicode, substitute_entites
- from calibre.utils.cleantext import clean_xml_chars
+ from ebook_converter.ebooks.chardet import strip_encoding_declarations, xml_to_unicode, substitute_entites
+ from ebook_converter.utils.cleantext import clean_xml_chars
if isinstance(markup, unicode_type):
markup = strip_encoding_declarations(markup)
markup = substitute_entites(markup)
diff --git a/ebook_converter/ebooks/__init__.py b/ebook_converter/ebooks/__init__.py
index a88f751..a3b11dd 100644
--- a/ebook_converter/ebooks/__init__.py
+++ b/ebook_converter/ebooks/__init__.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
@@ -9,9 +7,9 @@ from various formats.
'''
import os, re, numbers, sys
-from calibre import prints
-from calibre.ebooks.chardet import xml_to_unicode
-from polyglot.builtins import unicode_type
+from ebook_converter import prints
+from ebook_converter.ebooks.chardet import xml_to_unicode
+from ebook_converter.polyglot.builtins import unicode_type
class ConversionError(Exception):
@@ -42,7 +40,7 @@ BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'txtz', 'text', 'ht
def return_raster_image(path):
- from calibre.utils.imghdr import what
+ from ebook_converter.utils.imghdr import what
if os.access(path, os.R_OK):
with open(path, 'rb') as f:
raw = f.read()
@@ -51,8 +49,8 @@ def return_raster_image(path):
def extract_cover_from_embedded_svg(html, base, log):
- from calibre.ebooks.oeb.base import XPath, SVG, XLINK
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.oeb.base import XPath, SVG, XLINK
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
root = safe_xml_fromstring(html)
svg = XPath('//svg:svg')(root)
@@ -65,7 +63,7 @@ def extract_cover_from_embedded_svg(html, base, log):
def extract_calibre_cover(raw, base, log):
- from calibre.ebooks.BeautifulSoup import BeautifulSoup
+ from ebook_converter.ebooks.BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(raw)
matches = soup.find(name=['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span',
'font', 'br'])
@@ -93,7 +91,7 @@ def extract_calibre_cover(raw, base, log):
def render_html_svg_workaround(path_to_html, log, width=590, height=750):
- from calibre.ebooks.oeb.base import SVG_NS
+ from ebook_converter.ebooks.oeb.base import SVG_NS
with open(path_to_html, 'rb') as f:
raw = f.read()
raw = xml_to_unicode(raw, strip_encoding_pats=True)[0]
@@ -116,8 +114,8 @@ def render_html_svg_workaround(path_to_html, log, width=590, height=750):
def render_html_data(path_to_html, width, height):
- from calibre.ptempfile import TemporaryDirectory
- from calibre.utils.ipc.simple_worker import fork_job, WorkerError
+ from ebook_converter.ptempfile import TemporaryDirectory
+ from ebook_converter.utils.ipc.simple_worker import fork_job, WorkerError
result = {}
def report_error(text=''):
@@ -130,7 +128,7 @@ def render_html_data(path_to_html, width, height):
with TemporaryDirectory('-render-html') as tdir:
try:
- result = fork_job('calibre.ebooks.render_html', 'main', args=(path_to_html, tdir, 'jpeg'))
+ result = fork_job('ebook_converter.ebooks.render_html', 'main', args=(path_to_html, tdir, 'jpeg'))
except WorkerError as e:
report_error(e.orig_tb)
else:
@@ -163,8 +161,8 @@ def calibre_cover(title, author_string, series_string=None,
title = normalize(title)
author_string = normalize(author_string)
series_string = normalize(series_string)
- from calibre.ebooks.covers import calibre_cover2
- from calibre.utils.img import image_to_data
+ from ebook_converter.ebooks.covers import calibre_cover2
+ from ebook_converter.utils.img import image_to_data
ans = calibre_cover2(title, author_string or '', series_string or '', logo_path=logo_path, as_qimage=True)
return image_to_data(ans, fmt=output_format)
@@ -226,10 +224,10 @@ def parse_css_length(value):
def generate_masthead(title, output_path=None, width=600, height=60):
- from calibre.ebooks.conversion.config import load_defaults
+ from ebook_converter.ebooks.conversion.config import load_defaults
recs = load_defaults('mobi_output')
masthead_font_family = recs.get('masthead_font', None)
- from calibre.ebooks.covers import generate_masthead
+ from ebook_converter.ebooks.covers import generate_masthead
return generate_masthead(title, output_path=output_path, width=width, height=height, font_family=masthead_font_family)
diff --git a/ebook_converter/ebooks/chardet.py b/ebook_converter/ebooks/chardet.py
index 8abe1ff..9569476 100644
--- a/ebook_converter/ebooks/chardet.py
+++ b/ebook_converter/ebooks/chardet.py
@@ -7,7 +7,7 @@ __copyright__ = '2009, Kovid Goyal '
__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])
diff --git a/ebook_converter/ebooks/compression/__init__.py b/ebook_converter/ebooks/compression/__init__.py
index c2b7016..e69de29 100644
--- a/ebook_converter/ebooks/compression/__init__.py
+++ b/ebook_converter/ebooks/compression/__init__.py
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL 3'
-__copyright__ = '2009, John Schember '
-__docformat__ = 'restructuredtext en'
diff --git a/ebook_converter/ebooks/compression/palmdoc.c b/ebook_converter/ebooks/compression/palmdoc.c
index e415f37..5ff6a6f 100644
--- a/ebook_converter/ebooks/compression/palmdoc.c
+++ b/ebook_converter/ebooks/compression/palmdoc.c
@@ -219,11 +219,11 @@ static struct PyModuleDef cPalmdoc_module = {
/* m_clear */ 0,
/* m_free */ 0,
};
-CALIBRE_MODINIT_FUNC PyInit_cPalmdoc(void) {
+PyObject* PyInit_cPalmdoc(void) {
#else
#define INITERROR return
#define INITMODULE Py_InitModule3("cPalmdoc", cPalmdoc_methods, cPalmdoc_doc)
-CALIBRE_MODINIT_FUNC initcPalmdoc(void) {
+PyObject* initcPalmdoc(void) {
#endif
PyObject *m;
diff --git a/ebook_converter/ebooks/compression/palmdoc.py b/ebook_converter/ebooks/compression/palmdoc.py
index 6ce6ac5..9ac216e 100644
--- a/ebook_converter/ebooks/compression/palmdoc.py
+++ b/ebook_converter/ebooks/compression/palmdoc.py
@@ -8,12 +8,13 @@ __copyright__ = '2008, Kovid Goyal '
import io
from struct import pack
-from calibre.constants import plugins
-from polyglot.builtins import range
-cPalmdoc = plugins['cPalmdoc'][0]
-if not cPalmdoc:
- raise RuntimeError(('Failed to load required cPalmdoc module: '
- '%s')%plugins['cPalmdoc'][1])
+from ebook_converter.constants import plugins
+from ebook_converter.ebooks.compression import cPalmdoc
+from ebook_converter.polyglot.builtins import range
+#cPalmdoc = plugins['cPalmdoc'][0]
+#if not cPalmdoc:
+# raise RuntimeError(('Failed to load required cPalmdoc module: '
+# '%s')%plugins['cPalmdoc'][1])
def decompress_doc(data):
diff --git a/ebook_converter/ebooks/conversion/__init__.py b/ebook_converter/ebooks/conversion/__init__.py
index be49b37..bc93edd 100644
--- a/ebook_converter/ebooks/conversion/__init__.py
+++ b/ebook_converter/ebooks/conversion/__init__.py
@@ -5,7 +5,7 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from polyglot.builtins import native_string_type
+from ebook_converter.polyglot.builtins import native_string_type
class ConversionUserFeedBack(Exception):
@@ -27,4 +27,4 @@ class ConversionUserFeedBack(Exception):
# Ensure exception uses fully qualified name as this is used to detect it in
# the GUI.
-ConversionUserFeedBack.__name__ = native_string_type('calibre.ebooks.conversion.ConversionUserFeedBack')
+ConversionUserFeedBack.__name__ = native_string_type('ebook_converter.ebooks.conversion.ConversionUserFeedBack')
diff --git a/ebook_converter/ebooks/conversion/cli.py b/ebook_converter/ebooks/conversion/cli.py
index ce706ae..fa898e1 100644
--- a/ebook_converter/ebooks/conversion/cli.py
+++ b/ebook_converter/ebooks/conversion/cli.py
@@ -12,13 +12,13 @@ import sys, os, numbers
from optparse import OptionGroup, Option
from collections import OrderedDict
-from calibre.utils.config import OptionParser
-from calibre.utils.logging import Log
-from calibre.customize.conversion import OptionRecommendation
-from calibre import patheq
-from calibre.ebooks.conversion import ConversionUserFeedBack
-from calibre.utils.localization import localize_user_manual_link
-from polyglot.builtins import iteritems
+from ebook_converter.utils.config import OptionParser
+from ebook_converter.utils.logging import Log
+from ebook_converter.customize.conversion import OptionRecommendation
+from ebook_converter import patheq
+from ebook_converter.ebooks.conversion import ConversionUserFeedBack
+from ebook_converter.utils.localization import localize_user_manual_link
+from ebook_converter.polyglot.builtins import iteritems
USAGE = '%prog ' + _('''\
input_file output_file [options]
@@ -290,12 +290,12 @@ class ProgressBar(object):
def create_option_parser(args, log):
if '--version' in args:
- from calibre.constants import __appname__, __version__, __author__
+ from ebook_converter.constants import __appname__, __version__, __author__
log(os.path.basename(args[0]), '('+__appname__, __version__+')')
log('Created by:', __author__)
raise SystemExit(0)
if '--list-recipes' in args:
- from calibre.web.feeds.recipes.collection import get_builtin_recipe_titles
+ from ebook_converter.web.feeds.recipes.collection import get_builtin_recipe_titles
log('Available recipes:')
titles = sorted(get_builtin_recipe_titles())
for title in titles:
@@ -316,7 +316,7 @@ def create_option_parser(args, log):
input, output = check_command_line_options(parser, args, log)
- from calibre.ebooks.conversion.plumber import Plumber
+ from ebook_converter.ebooks.conversion.plumber import Plumber
reporter = ProgressBar(log)
if patheq(input, output):
@@ -380,7 +380,7 @@ def main(args=sys.argv):
if opts.search_replace:
opts.search_replace = read_sr_patterns(opts.search_replace, log)
if opts.transform_css_rules:
- from calibre.ebooks.css_transform_rules import import_rules, validate_rule
+ from ebook_converter.ebooks.css_transform_rules import import_rules, validate_rule
with open(opts.transform_css_rules, 'rb') as tcr:
opts.transform_css_rules = rules = list(import_rules(tcr.read()))
for rule in rules:
diff --git a/ebook_converter/ebooks/conversion/plugins/__init__.py b/ebook_converter/ebooks/conversion/plugins/__init__.py
index 357137f..e69de29 100644
--- a/ebook_converter/ebooks/conversion/plugins/__init__.py
+++ b/ebook_converter/ebooks/conversion/plugins/__init__.py
@@ -1,10 +0,0 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2012, Kovid Goyal '
-__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/ebook_converter/ebooks/conversion/plugins/azw4_input.py b/ebook_converter/ebooks/conversion/plugins/azw4_input.py
index d3a7e6a..3d496e5 100644
--- a/ebook_converter/ebooks/conversion/plugins/azw4_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/azw4_input.py
@@ -5,8 +5,8 @@ __license__ = 'GPL v3'
__copyright__ = '2011, John Schember '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import getcwd
class AZW4Input(InputFormatPlugin):
@@ -19,8 +19,8 @@ class AZW4Input(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.pdb.header import PdbHeaderReader
- from calibre.ebooks.azw4.reader import Reader
+ from ebook_converter.ebooks.pdb.header import PdbHeaderReader
+ from ebook_converter.ebooks.azw4.reader import Reader
header = PdbHeaderReader(stream)
reader = Reader(header, stream, log, options)
diff --git a/ebook_converter/ebooks/conversion/plugins/chm_input.py b/ebook_converter/ebooks/conversion/plugins/chm_input.py
index 44f5de5..5c8ae70 100644
--- a/ebook_converter/ebooks/conversion/plugins/chm_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/chm_input.py
@@ -7,10 +7,10 @@ __copyright__ = '2008, Kovid Goyal ,' \
import os
-from calibre.customize.conversion import InputFormatPlugin
-from calibre.ptempfile import TemporaryDirectory
-from calibre.constants import filesystem_encoding
-from polyglot.builtins import unicode_type, as_bytes
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.constants import filesystem_encoding
+from ebook_converter.polyglot.builtins import unicode_type, as_bytes
class CHMInput(InputFormatPlugin):
@@ -22,7 +22,7 @@ class CHMInput(InputFormatPlugin):
commit_name = 'chm_input'
def _chmtohtml(self, output_dir, chm_path, no_images, log, debug_dump=False):
- from calibre.ebooks.chm.reader import CHMReader
+ from ebook_converter.ebooks.chm.reader import CHMReader
log.debug('Opening CHM file')
rdr = CHMReader(chm_path, log, input_encoding=self.opts.input_encoding)
log.debug('Extracting CHM to %s' % output_dir)
@@ -31,8 +31,8 @@ class CHMInput(InputFormatPlugin):
return rdr.hhc_path
def convert(self, stream, options, file_ext, log, accelerators):
- from calibre.ebooks.chm.metadata import get_metadata_from_reader
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.ebooks.chm.metadata import get_metadata_from_reader
+ from ebook_converter.customize.ui import plugin_for_input_format
self.opts = options
log.debug('Processing CHM...')
@@ -62,12 +62,12 @@ class CHMInput(InputFormatPlugin):
metadata = get_metadata_from_reader(self._chm_reader)
except Exception:
log.exception('Failed to read metadata, using filename')
- from calibre.ebooks.metadata.book.base import Metadata
+ from ebook_converter.ebooks.metadata.book.base import Metadata
metadata = Metadata(os.path.basename(chm_name))
encoding = self._chm_reader.get_encoding() or options.input_encoding or 'cp1252'
self._chm_reader.CloseCHM()
# print((tdir, mainpath))
- # from calibre import ipython
+ # from ebook_converter import ipython
# ipython()
options.debug_pipeline = None
@@ -85,7 +85,7 @@ class CHMInput(InputFormatPlugin):
return oeb
def parse_html_toc(self, item):
- from calibre.ebooks.oeb.base import TOC, XPath
+ from ebook_converter.ebooks.oeb.base import TOC, XPath
dx = XPath('./h:div')
ax = XPath('./h:a[1]')
@@ -102,7 +102,7 @@ class CHMInput(InputFormatPlugin):
def _create_oebbook_html(self, htmlpath, basedir, opts, log, mi):
# use HTMLInput plugin to generate book
- from calibre.customize.builtins import HTMLInput
+ from ebook_converter.customize.builtins import HTMLInput
opts.breadth_first = True
htmlinput = HTMLInput(None)
oeb = htmlinput.create_oebbook(htmlpath, basedir, opts, log, mi)
@@ -110,9 +110,9 @@ class CHMInput(InputFormatPlugin):
def _create_html_root(self, hhcpath, log, encoding):
from lxml import html
- from polyglot.urllib import unquote as _unquote
- from calibre.ebooks.oeb.base import urlquote
- from calibre.ebooks.chardet import xml_to_unicode
+ from ebook_converter.polyglot.urllib import unquote as _unquote
+ from ebook_converter.ebooks.oeb.base import urlquote
+ from ebook_converter.ebooks.chardet import xml_to_unicode
hhcdata = self._read_file(hhcpath)
hhcdata = hhcdata.decode(encoding)
hhcdata = xml_to_unicode(hhcdata, verbose=True,
@@ -179,7 +179,7 @@ class CHMInput(InputFormatPlugin):
return data
def add_node(self, node, toc, ancestor_map):
- from calibre.ebooks.chm.reader import match_string
+ from ebook_converter.ebooks.chm.reader import match_string
if match_string(node.attrib.get('type', ''), 'text/sitemap'):
p = node.xpath('ancestor::ul[1]/ancestor::li[1]/object[1]')
parent = p[0] if p else None
@@ -194,7 +194,7 @@ class CHMInput(InputFormatPlugin):
ancestor_map[node] = child
def _process_nodes(self, root):
- from calibre.ebooks.oeb.base import TOC
+ from ebook_converter.ebooks.oeb.base import TOC
toc = TOC()
ancestor_map = {}
for node in root.xpath('//object'):
diff --git a/ebook_converter/ebooks/conversion/plugins/comic_input.py b/ebook_converter/ebooks/conversion/plugins/comic_input.py
index 079e12b..335b53d 100644
--- a/ebook_converter/ebooks/conversion/plugins/comic_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/comic_input.py
@@ -10,10 +10,10 @@ Based on ideas from comiclrf created by FangornUK.
import shutil, textwrap, codecs, os
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from calibre import CurrentDir
-from calibre.ptempfile import PersistentTemporaryDirectory
-from polyglot.builtins import getcwd, map
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter import CurrentDir
+from ebook_converter.ptempfile import PersistentTemporaryDirectory
+from ebook_converter.polyglot.builtins import getcwd, map
class ComicInput(InputFormatPlugin):
@@ -93,7 +93,7 @@ class ComicInput(InputFormatPlugin):
}
def get_comics_from_collection(self, stream):
- from calibre.libunzip import extract as zipextract
+ from ebook_converter.libunzip import extract as zipextract
tdir = PersistentTemporaryDirectory('_comic_collection')
zipextract(stream, tdir)
comics = []
@@ -129,7 +129,7 @@ class ComicInput(InputFormatPlugin):
return comics
def get_pages(self, comic, tdir2):
- from calibre.ebooks.comic.input import (extract_comic, process_pages,
+ from ebook_converter.ebooks.comic.input import (extract_comic, process_pages,
find_pages)
tdir = extract_comic(comic)
new_pages = find_pages(tdir, sort_on_mtime=self.opts.no_sort,
@@ -165,9 +165,9 @@ class ComicInput(InputFormatPlugin):
return self._images
def convert(self, stream, opts, file_ext, log, accelerators):
- from calibre.ebooks.metadata import MetaInformation
- from calibre.ebooks.metadata.opf2 import OPFCreator
- from calibre.ebooks.metadata.toc import TOC
+ from ebook_converter.ebooks.metadata import MetaInformation
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.ebooks.metadata.toc import TOC
self.opts, self.log= opts, log
if file_ext == 'cbc':
@@ -245,7 +245,7 @@ class ComicInput(InputFormatPlugin):
return os.path.abspath('metadata.opf')
def create_wrappers(self, pages):
- from calibre.ebooks.oeb.base import XHTML_NS
+ from ebook_converter.ebooks.oeb.base import XHTML_NS
wrappers = []
WRAPPER = textwrap.dedent('''\
@@ -275,7 +275,7 @@ class ComicInput(InputFormatPlugin):
return wrappers
def create_viewer_wrapper(self, pages):
- from calibre.ebooks.oeb.base import XHTML_NS
+ from ebook_converter.ebooks.oeb.base import XHTML_NS
def page(src):
return '
'.format(os.path.basename(src))
diff --git a/ebook_converter/ebooks/conversion/plugins/djvu_input.py b/ebook_converter/ebooks/conversion/plugins/djvu_input.py
index ed61ff0..e40e0b7 100644
--- a/ebook_converter/ebooks/conversion/plugins/djvu_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/djvu_input.py
@@ -9,8 +9,8 @@ __docformat__ = 'restructuredtext en'
import os
from io import BytesIO
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import getcwd
class DJVUInput(InputFormatPlugin):
@@ -22,10 +22,10 @@ class DJVUInput(InputFormatPlugin):
commit_name = 'djvu_input'
def convert(self, stream, options, file_ext, log, accelerators):
- from calibre.ebooks.txt.processor import convert_basic
+ from ebook_converter.ebooks.txt.processor import convert_basic
stdout = BytesIO()
- from calibre.ebooks.djvu.djvu import DJVUFile
+ from ebook_converter.ebooks.djvu.djvu import DJVUFile
x = DJVUFile(stream)
x.get_text(stdout)
raw_text = stdout.getvalue()
@@ -36,7 +36,7 @@ class DJVUInput(InputFormatPlugin):
html = convert_basic(raw_text.replace(b"\n", b' ').replace(
b'\037', b'\n\n'))
# Run the HTMLized text through the html processing plugin.
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
html_input = plugin_for_input_format('html')
for opt in html_input.options:
setattr(options, opt.option.name, opt.recommended_value)
@@ -59,8 +59,8 @@ class DJVUInput(InputFormatPlugin):
os.remove(htmlfile)
# Set metadata from file.
- from calibre.customize.ui import get_file_type_metadata
- from calibre.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
+ from ebook_converter.customize.ui import get_file_type_metadata
+ from ebook_converter.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
mi = get_file_type_metadata(stream, file_ext)
meta_info_to_oeb_metadata(mi, oeb.metadata, log)
diff --git a/ebook_converter/ebooks/conversion/plugins/docx_input.py b/ebook_converter/ebooks/conversion/plugins/docx_input.py
index 2ba157e..54283cb 100644
--- a/ebook_converter/ebooks/conversion/plugins/docx_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/docx_input.py
@@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
class DOCXInput(InputFormatPlugin):
@@ -29,6 +29,6 @@ class DOCXInput(InputFormatPlugin):
recommendations = {('page_breaks_before', '/', OptionRecommendation.MED)}
def convert(self, stream, options, file_ext, log, accelerators):
- from calibre.ebooks.docx.to_html import Convert
+ from ebook_converter.ebooks.docx.to_html import Convert
return Convert(stream, detect_cover=not options.docx_no_cover, log=log, notes_nopb=options.docx_no_pagebreaks_between_notes,
nosupsub=options.docx_inline_subsup)()
diff --git a/ebook_converter/ebooks/conversion/plugins/docx_output.py b/ebook_converter/ebooks/conversion/plugins/docx_output.py
index ab65e87..1a608f3 100644
--- a/ebook_converter/ebooks/conversion/plugins/docx_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/docx_output.py
@@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
+from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation
PAGE_SIZES = ['a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'b0', 'b1',
'b2', 'b3', 'b4', 'b5', 'b6', 'legal', 'letter']
@@ -74,20 +74,20 @@ class DOCXOutput(OutputFormatPlugin):
def convert_metadata(self, oeb):
from lxml import etree
- from calibre.ebooks.oeb.base import OPF, OPF2_NS
- from calibre.ebooks.metadata.opf2 import OPF as ReadOPF
+ from ebook_converter.ebooks.oeb.base import OPF, OPF2_NS
+ from ebook_converter.ebooks.metadata.opf2 import OPF as ReadOPF
from io import BytesIO
package = etree.Element(OPF('package'), attrib={'version': '2.0'}, nsmap={None: OPF2_NS})
oeb.metadata.to_opf2(package)
self.mi = ReadOPF(BytesIO(etree.tostring(package, encoding='utf-8')), populate_spine=False, try_to_guess_cover=False).to_book_metadata()
def convert(self, oeb, output_path, input_plugin, opts, log):
- from calibre.ebooks.docx.writer.container import DOCX
- from calibre.ebooks.docx.writer.from_html import Convert
+ from ebook_converter.ebooks.docx.writer.container import DOCX
+ from ebook_converter.ebooks.docx.writer.from_html import Convert
docx = DOCX(opts, log)
self.convert_metadata(oeb)
Convert(oeb, docx, self.mi, not opts.docx_no_cover, not opts.docx_no_toc)()
docx.write(output_path, self.mi)
if opts.extract_to:
- from calibre.ebooks.docx.dump import do_dump
+ from ebook_converter.ebooks.docx.dump import do_dump
do_dump(output_path, opts.extract_to)
diff --git a/ebook_converter/ebooks/conversion/plugins/epub_input.py b/ebook_converter/ebooks/conversion/plugins/epub_input.py
index 7c60b0e..aeda324 100644
--- a/ebook_converter/ebooks/conversion/plugins/epub_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/epub_input.py
@@ -7,8 +7,8 @@ __docformat__ = 'restructuredtext en'
import os, re, posixpath
from itertools import cycle
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.polyglot.builtins import getcwd
ADOBE_OBFUSCATION = 'http://ns.adobe.com/pdf/enc#RC'
IDPF_OBFUSCATION = 'http://www.idpf.org/2008/embedding'
@@ -101,7 +101,7 @@ class EPUBInput(InputFormatPlugin):
def rationalize_cover3(self, opf, log):
''' If there is a reference to the cover/titlepage via manifest properties, convert to
entries in the so that the rest of the pipeline picks it up. '''
- from calibre.ebooks.metadata.opf3 import items_with_property
+ from ebook_converter.ebooks.metadata.opf3 import items_with_property
removed = guide_titlepage_href = guide_titlepage_id = None
# Look for titlepages incorrectly marked in the as covers
@@ -150,7 +150,7 @@ class EPUBInput(InputFormatPlugin):
means, at most one entry with type="cover" that points to a raster
cover and at most one entry with type="titlepage" that points to an
HTML titlepage. '''
- from calibre.ebooks.oeb.base import OPF
+ from ebook_converter.ebooks.oeb.base import OPF
removed = None
from lxml import etree
guide_cover, guide_elem = None, None
@@ -215,7 +215,7 @@ class EPUBInput(InputFormatPlugin):
guide_elem.set('href', raster_cover)
else:
# Render the titlepage to create a raster cover
- from calibre.ebooks import render_html_svg_workaround
+ from ebook_converter.ebooks import render_html_svg_workaround
guide_elem.set('href', 'calibre_raster_cover.jpg')
t = etree.SubElement(
elem[0].getparent(), OPF('item'), href=guide_elem.get('href'), id='calibre_raster_cover')
@@ -231,7 +231,7 @@ class EPUBInput(InputFormatPlugin):
return removed
def find_opf(self):
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
def attr(n, attr):
for k, v in n.attrib.items():
@@ -254,17 +254,17 @@ class EPUBInput(InputFormatPlugin):
traceback.print_exc()
def convert(self, stream, options, file_ext, log, accelerators):
- from calibre.utils.zipfile import ZipFile
- from calibre import walk
- from calibre.ebooks import DRMError
- from calibre.ebooks.metadata.opf2 import OPF
+ from ebook_converter.utils.zipfile import ZipFile
+ from ebook_converter import walk
+ from ebook_converter.ebooks import DRMError
+ from ebook_converter.ebooks.metadata.opf2 import OPF
try:
zf = ZipFile(stream)
zf.extractall(getcwd())
except:
log.exception('EPUB appears to be invalid ZIP file, trying a'
' more forgiving ZIP parser')
- from calibre.utils.localunzip import extractall
+ from ebook_converter.utils.localunzip import extractall
stream.seek(0)
extractall(stream)
encfile = os.path.abspath(os.path.join('META-INF', 'encryption.xml'))
@@ -352,11 +352,11 @@ class EPUBInput(InputFormatPlugin):
def convert_epub3_nav(self, nav_path, opf, log, opts):
from lxml import etree
- from calibre.ebooks.chardet import xml_to_unicode
- from calibre.ebooks.oeb.polish.parsing import parse
- from calibre.ebooks.oeb.base import EPUB_NS, XHTML, NCX_MIME, NCX, urlnormalize, urlunquote, serialize
- from calibre.ebooks.oeb.polish.toc import first_child
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.chardet import xml_to_unicode
+ from ebook_converter.ebooks.oeb.polish.parsing import parse
+ from ebook_converter.ebooks.oeb.base import EPUB_NS, XHTML, NCX_MIME, NCX, urlnormalize, urlunquote, serialize
+ from ebook_converter.ebooks.oeb.polish.toc import first_child
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
from tempfile import NamedTemporaryFile
with lopen(nav_path, 'rb') as f:
raw = f.read()
diff --git a/ebook_converter/ebooks/conversion/plugins/epub_output.py b/ebook_converter/ebooks/conversion/plugins/epub_output.py
index 2265508..e2407f6 100644
--- a/ebook_converter/ebooks/conversion/plugins/epub_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/epub_output.py
@@ -8,11 +8,11 @@ __docformat__ = 'restructuredtext en'
import os, shutil, re
-from calibre.customize.conversion import (OutputFormatPlugin,
+from ebook_converter.customize.conversion import (OutputFormatPlugin,
OptionRecommendation)
-from calibre.ptempfile import TemporaryDirectory
-from calibre import CurrentDir
-from polyglot.builtins import unicode_type, filter, map, zip, range, as_bytes
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter import CurrentDir
+from ebook_converter.polyglot.builtins import unicode_type, filter, map, zip, range, as_bytes
block_level_tags = (
'address',
@@ -130,7 +130,7 @@ class EPUBOutput(OutputFormatPlugin):
recommendations = {('pretty_print', True, OptionRecommendation.HIGH)}
def workaround_webkit_quirks(self): # {{{
- from calibre.ebooks.oeb.base import XPath
+ from ebook_converter.ebooks.oeb.base import XPath
for x in self.oeb.spine:
root = x.data
body = XPath('//h:body')(root)
@@ -147,7 +147,7 @@ class EPUBOutput(OutputFormatPlugin):
def upshift_markup(self): # {{{
'Upgrade markup to comply with XHTML 1.1 where possible'
- from calibre.ebooks.oeb.base import XPath, XML
+ from ebook_converter.ebooks.oeb.base import XPath, XML
for x in self.oeb.spine:
root = x.data
if (not root.get(XML('lang'))) and (root.get('lang')):
@@ -181,32 +181,32 @@ class EPUBOutput(OutputFormatPlugin):
self.log, self.opts, self.oeb = log, opts, oeb
if self.opts.epub_inline_toc:
- from calibre.ebooks.mobi.writer8.toc import TOCAdder
+ from ebook_converter.ebooks.mobi.writer8.toc import TOCAdder
opts.mobi_toc_at_start = not opts.epub_toc_at_end
opts.mobi_passthrough = False
opts.no_inline_toc = False
TOCAdder(oeb, opts, replace_previous_inline_toc=True, ignore_existing_toc=True)
if self.opts.epub_flatten:
- from calibre.ebooks.oeb.transforms.filenames import FlatFilenames
+ from ebook_converter.ebooks.oeb.transforms.filenames import FlatFilenames
FlatFilenames()(oeb, opts)
else:
- from calibre.ebooks.oeb.transforms.filenames import UniqueFilenames
+ from ebook_converter.ebooks.oeb.transforms.filenames import UniqueFilenames
UniqueFilenames()(oeb, opts)
self.workaround_ade_quirks()
self.workaround_webkit_quirks()
self.upshift_markup()
- from calibre.ebooks.oeb.transforms.rescale import RescaleImages
+ from ebook_converter.ebooks.oeb.transforms.rescale import RescaleImages
RescaleImages(check_colorspaces=True)(oeb, opts)
- from calibre.ebooks.oeb.transforms.split import Split
+ from ebook_converter.ebooks.oeb.transforms.split import Split
split = Split(not self.opts.dont_split_on_page_breaks,
max_flow_size=self.opts.flow_size*1024
)
split(self.oeb, self.opts)
- from calibre.ebooks.oeb.transforms.cover import CoverManager
+ from ebook_converter.ebooks.oeb.transforms.cover import CoverManager
cm = CoverManager(
no_default_cover=self.opts.no_default_epub_cover,
no_svg_cover=self.opts.no_svg_cover,
@@ -221,7 +221,7 @@ class EPUBOutput(OutputFormatPlugin):
first = next(iter(self.oeb.spine))
self.oeb.toc.add(_('Start'), first.href)
- from calibre.ebooks.oeb.base import OPF
+ from ebook_converter.ebooks.oeb.base import OPF
identifiers = oeb.metadata['identifier']
uuid = None
for x in identifiers:
@@ -245,12 +245,12 @@ class EPUBOutput(OutputFormatPlugin):
x.content = 'urn:uuid:'+uuid
with TemporaryDirectory('_epub_output') as tdir:
- from calibre.customize.ui import plugin_for_output_format
+ from ebook_converter.customize.ui import plugin_for_output_format
metadata_xml = None
extra_entries = []
if self.is_periodical:
if self.opts.output_profile.epub_periodical_format == 'sony':
- from calibre.ebooks.epub.periodical import sony_metadata
+ from ebook_converter.ebooks.epub.periodical import sony_metadata
metadata_xml, atom_xml = sony_metadata(oeb)
extra_entries = [('atom.xml', 'application/atom+xml', atom_xml)]
oeb_output = plugin_for_output_format('oeb')
@@ -264,7 +264,7 @@ class EPUBOutput(OutputFormatPlugin):
if encrypted_fonts:
encryption = self.encrypt_fonts(encrypted_fonts, tdir, uuid)
- from calibre.ebooks.epub import initialize_container
+ from ebook_converter.ebooks.epub import initialize_container
with initialize_container(output_path, os.path.basename(opf),
extra_entries=extra_entries) as epub:
epub.add_dir(tdir)
@@ -274,7 +274,7 @@ class EPUBOutput(OutputFormatPlugin):
epub.writestr('META-INF/metadata.xml',
metadata_xml.encode('utf-8'))
if opts.extract_to is not None:
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
if os.path.exists(opts.extract_to):
if os.path.isdir(opts.extract_to):
shutil.rmtree(opts.extract_to)
@@ -287,17 +287,17 @@ class EPUBOutput(OutputFormatPlugin):
def upgrade_to_epub3(self, tdir, opf):
self.log.info('Upgrading to EPUB 3...')
- from calibre.ebooks.epub import simple_container_xml
- from calibre.ebooks.oeb.polish.cover import fix_conversion_titlepage_links_in_nav
+ from ebook_converter.ebooks.epub import simple_container_xml
+ from ebook_converter.ebooks.oeb.polish.cover import fix_conversion_titlepage_links_in_nav
try:
os.mkdir(os.path.join(tdir, 'META-INF'))
except EnvironmentError:
pass
with open(os.path.join(tdir, 'META-INF', 'container.xml'), 'wb') as f:
f.write(simple_container_xml(os.path.basename(opf)).encode('utf-8'))
- from calibre.ebooks.oeb.polish.container import EpubContainer
+ from ebook_converter.ebooks.oeb.polish.container import EpubContainer
container = EpubContainer(tdir, self.log)
- from calibre.ebooks.oeb.polish.upgrade import epub_2_to_3
+ from ebook_converter.ebooks.oeb.polish.upgrade import epub_2_to_3
existing_nav = getattr(self.opts, 'epub3_nav_parsed', None)
nav_href = getattr(self.opts, 'epub3_nav_href', None)
previous_nav = (nav_href, existing_nav) if existing_nav and nav_href else None
@@ -311,7 +311,7 @@ class EPUBOutput(OutputFormatPlugin):
pass
def encrypt_fonts(self, uris, tdir, uuid): # {{{
- from polyglot.binary import from_hex_bytes
+ from ebook_converter.polyglot.binary import from_hex_bytes
key = re.sub(r'[^a-fA-F0-9]', '', uuid)
if len(key) < 16:
@@ -376,7 +376,7 @@ class EPUBOutput(OutputFormatPlugin):
Perform various markup transforms to get the output to render correctly
in the quirky ADE.
'''
- from calibre.ebooks.oeb.base import XPath, XHTML, barename, urlunquote
+ from ebook_converter.ebooks.oeb.base import XPath, XHTML, barename, urlunquote
stylesheet = self.oeb.manifest.main_stylesheet
@@ -517,8 +517,8 @@ class EPUBOutput(OutputFormatPlugin):
'''
Perform toc link transforms to alleviate slow loading.
'''
- from calibre.ebooks.oeb.base import urldefrag, XPath
- from calibre.ebooks.oeb.polish.toc import item_at_top
+ from ebook_converter.ebooks.oeb.base import urldefrag, XPath
+ from ebook_converter.ebooks.oeb.polish.toc import item_at_top
def frag_is_at_top(root, frag):
elem = XPath('//*[@id="%s" or @name="%s"]'%(frag, frag))(root)
diff --git a/ebook_converter/ebooks/conversion/plugins/fb2_input.py b/ebook_converter/ebooks/conversion/plugins/fb2_input.py
index d82220d..bddb692 100644
--- a/ebook_converter/ebooks/conversion/plugins/fb2_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/fb2_input.py
@@ -7,9 +7,9 @@ Convert .fb2 files to .lrf
"""
import os, re
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from calibre import guess_type
-from polyglot.builtins import iteritems, getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter import guess_type
+from ebook_converter.polyglot.builtins import iteritems, getcwd
FB2NS = 'http://www.gribuser.ru/xml/fictionbook/2.0'
FB21NS = 'http://www.gribuser.ru/xml/fictionbook/2.1'
@@ -39,12 +39,12 @@ class FB2Input(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
from lxml import etree
- from calibre.utils.xml_parse import safe_xml_fromstring
- from calibre.ebooks.metadata.fb2 import ensure_namespace, get_fb2_data
- from calibre.ebooks.metadata.opf2 import OPFCreator
- from calibre.ebooks.metadata.meta import get_metadata
- from calibre.ebooks.oeb.base import XLINK_NS, XHTML_NS
- from calibre.ebooks.chardet import xml_to_unicode
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.metadata.fb2 import ensure_namespace, get_fb2_data
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.ebooks.metadata.meta import get_metadata
+ from ebook_converter.ebooks.oeb.base import XLINK_NS, XHTML_NS
+ from ebook_converter.ebooks.chardet import xml_to_unicode
self.log = log
log.debug('Parsing XML...')
raw = get_fb2_data(stream)[0]
@@ -156,7 +156,7 @@ class FB2Input(InputFormatPlugin):
return os.path.join(getcwd(), 'metadata.opf')
def extract_embedded_content(self, doc):
- from calibre.ebooks.fb2 import base64_decode
+ from ebook_converter.ebooks.fb2 import base64_decode
self.binary_map = {}
for elem in doc.xpath('./*'):
if elem.text and 'binary' in elem.tag and 'id' in elem.attrib:
diff --git a/ebook_converter/ebooks/conversion/plugins/fb2_output.py b/ebook_converter/ebooks/conversion/plugins/fb2_output.py
index ce99457..5f8f91e 100644
--- a/ebook_converter/ebooks/conversion/plugins/fb2_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/fb2_output.py
@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
+from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation
class FB2Output(OutputFormatPlugin):
@@ -171,9 +171,9 @@ class FB2Output(OutputFormatPlugin):
}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.oeb.transforms.jacket import linearize_jacket
- from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
- from calibre.ebooks.fb2.fb2ml import FB2MLizer
+ from ebook_converter.ebooks.oeb.transforms.jacket import linearize_jacket
+ from ebook_converter.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
+ from ebook_converter.ebooks.fb2.fb2ml import FB2MLizer
try:
rasterizer = SVGRasterizer()
diff --git a/ebook_converter/ebooks/conversion/plugins/html_input.py b/ebook_converter/ebooks/conversion/plugins/html_input.py
index b74cfba..6ba979c 100644
--- a/ebook_converter/ebooks/conversion/plugins/html_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/html_input.py
@@ -9,13 +9,13 @@ __docformat__ = 'restructuredtext en'
import re, tempfile, os
from functools import partial
-from calibre.constants import islinux, isbsd
-from calibre.customize.conversion import (InputFormatPlugin,
+from ebook_converter.constants import islinux, isbsd
+from ebook_converter.customize.conversion import (InputFormatPlugin,
OptionRecommendation)
-from calibre.utils.localization import get_lang
-from calibre.utils.filenames import ascii_filename
-from calibre.utils.imghdr import what
-from polyglot.builtins import unicode_type, zip, getcwd, as_unicode
+from ebook_converter.utils.localization import get_lang
+from ebook_converter.utils.filenames import ascii_filename
+from ebook_converter.utils.imghdr import what
+from ebook_converter.polyglot.builtins import unicode_type, zip, getcwd, as_unicode
def sanitize_file_name(x):
@@ -74,17 +74,17 @@ class HTMLInput(InputFormatPlugin):
if file_ext != 'opf':
if opts.dont_package:
raise ValueError('The --dont-package option is not supported for an HTML input file')
- from calibre.ebooks.metadata.html import get_metadata
+ from ebook_converter.ebooks.metadata.html import get_metadata
mi = get_metadata(stream)
if fname:
- from calibre.ebooks.metadata.meta import metadata_from_filename
+ from ebook_converter.ebooks.metadata.meta import metadata_from_filename
fmi = metadata_from_filename(fname)
fmi.smart_update(mi)
mi = fmi
oeb = self.create_oebbook(stream.name, basedir, opts, log, mi)
return oeb
- from calibre.ebooks.conversion.plumber import create_oebbook
+ from ebook_converter.ebooks.conversion.plumber import create_oebbook
return create_oebbook(log, stream.name, opts,
encoding=opts.input_encoding)
@@ -98,16 +98,16 @@ class HTMLInput(InputFormatPlugin):
def create_oebbook(self, htmlpath, basedir, opts, log, mi):
import uuid
- from calibre.ebooks.conversion.plumber import create_oebbook
- from calibre.ebooks.oeb.base import (DirContainer,
+ from ebook_converter.ebooks.conversion.plumber import create_oebbook
+ from ebook_converter.ebooks.oeb.base import (DirContainer,
rewrite_links, urlnormalize, urldefrag, BINARY_MIME, OEB_STYLES,
xpath, urlquote)
- from calibre import guess_type
- from calibre.ebooks.oeb.transforms.metadata import \
+ from ebook_converter import guess_type
+ from ebook_converter.ebooks.oeb.transforms.metadata import \
meta_info_to_oeb_metadata
- from calibre.ebooks.html.input import get_filelist
- from calibre.ebooks.metadata import string_to_authors
- from calibre.utils.localization import canonicalize_lang
+ from ebook_converter.ebooks.html.input import get_filelist
+ from ebook_converter.ebooks.metadata import string_to_authors
+ from ebook_converter.utils.localization import canonicalize_lang
import css_parser, logging
css_parser.log.setLevel(logging.WARN)
self.OEB_STYLES = OEB_STYLES
@@ -223,7 +223,7 @@ class HTMLInput(InputFormatPlugin):
return oeb
def link_to_local_path(self, link_, base=None):
- from calibre.ebooks.html.input import Link
+ from ebook_converter.ebooks.html.input import Link
if not isinstance(link_, unicode_type):
try:
link_ = link_.decode('utf-8', 'error')
@@ -245,7 +245,7 @@ class HTMLInput(InputFormatPlugin):
return link, frag
def resource_adder(self, link_, base=None):
- from polyglot.urllib import quote
+ from ebook_converter.polyglot.urllib import quote
link, frag = self.link_to_local_path(link_, base=base)
if link is None:
return link_
diff --git a/ebook_converter/ebooks/conversion/plugins/html_output.py b/ebook_converter/ebooks/conversion/plugins/html_output.py
index b45c3c6..af839d5 100644
--- a/ebook_converter/ebooks/conversion/plugins/html_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/html_output.py
@@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
import os, re, shutil
from os.path import dirname, abspath, relpath as _relpath, exists, basename
-from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
-from calibre import CurrentDir
-from calibre.ptempfile import PersistentTemporaryDirectory
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation
+from ebook_converter import CurrentDir
+from ebook_converter.ptempfile import PersistentTemporaryDirectory
+from ebook_converter.polyglot.builtins import unicode_type
def relpath(*args):
@@ -48,10 +48,10 @@ class HTMLOutput(OutputFormatPlugin):
Generate table of contents
'''
from lxml import etree
- from polyglot.urllib import unquote
+ from ebook_converter.polyglot.urllib import unquote
- from calibre.ebooks.oeb.base import element
- from calibre.utils.cleantext import clean_xml_chars
+ from ebook_converter.ebooks.oeb.base import element
+ from ebook_converter.utils.cleantext import clean_xml_chars
with CurrentDir(output_dir):
def build_node(current_node, parent=None):
if parent is None:
@@ -85,10 +85,10 @@ class HTMLOutput(OutputFormatPlugin):
def convert(self, oeb_book, output_path, input_plugin, opts, log):
from lxml import etree
- from calibre.utils import zipfile
+ from ebook_converter.utils import zipfile
from templite import Templite
- from polyglot.urllib import unquote
- from calibre.ebooks.html.meta import EasyMeta
+ from ebook_converter.polyglot.urllib import unquote
+ from ebook_converter.ebooks.html.meta import EasyMeta
# read template files
if opts.template_html_index is not None:
diff --git a/ebook_converter/ebooks/conversion/plugins/htmlz_input.py b/ebook_converter/ebooks/conversion/plugins/htmlz_input.py
index baed0c1..f0dfe1b 100644
--- a/ebook_converter/ebooks/conversion/plugins/htmlz_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/htmlz_input.py
@@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre import guess_type
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import getcwd
+from ebook_converter import guess_type
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import getcwd
class HTMLZInput(InputFormatPlugin):
@@ -23,9 +23,9 @@ class HTMLZInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.chardet import xml_to_unicode
- from calibre.ebooks.metadata.opf2 import OPF
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.chardet import xml_to_unicode
+ from ebook_converter.ebooks.metadata.opf2 import OPF
+ from ebook_converter.utils.zipfile import ZipFile
self.log = log
html = u''
@@ -82,7 +82,7 @@ class HTMLZInput(InputFormatPlugin):
html = html.decode(ienc, 'replace')
# Run the HTML through the html processing plugin.
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
html_input = plugin_for_input_format('html')
for opt in html_input.options:
setattr(options, opt.option.name, opt.recommended_value)
@@ -105,8 +105,8 @@ class HTMLZInput(InputFormatPlugin):
os.remove(htmlfile)
# Set metadata from file.
- from calibre.customize.ui import get_file_type_metadata
- from calibre.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
+ from ebook_converter.customize.ui import get_file_type_metadata
+ from ebook_converter.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
mi = get_file_type_metadata(stream, file_ext)
meta_info_to_oeb_metadata(mi, oeb.metadata, log)
diff --git a/ebook_converter/ebooks/conversion/plugins/htmlz_output.py b/ebook_converter/ebooks/conversion/plugins/htmlz_output.py
index c72fd09..1ed11c9 100644
--- a/ebook_converter/ebooks/conversion/plugins/htmlz_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/htmlz_output.py
@@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
import io
import os
-from calibre.customize.conversion import OutputFormatPlugin, \
+from ebook_converter.customize.conversion import OutputFormatPlugin, \
OptionRecommendation
-from calibre.ptempfile import TemporaryDirectory
-from polyglot.builtins import unicode_type
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.polyglot.builtins import unicode_type
class HTMLZOutput(OutputFormatPlugin):
@@ -59,20 +59,20 @@ class HTMLZOutput(OutputFormatPlugin):
def convert(self, oeb_book, output_path, input_plugin, opts, log):
from lxml import etree
- from calibre.ebooks.oeb.base import OEB_IMAGES, SVG_MIME
- from calibre.ebooks.metadata.opf2 import OPF, metadata_to_opf
- from calibre.utils.zipfile import ZipFile
- from calibre.utils.filenames import ascii_filename
+ from ebook_converter.ebooks.oeb.base import OEB_IMAGES, SVG_MIME
+ from ebook_converter.ebooks.metadata.opf2 import OPF, metadata_to_opf
+ from ebook_converter.utils.zipfile import ZipFile
+ from ebook_converter.utils.filenames import ascii_filename
# HTML
if opts.htmlz_css_type == 'inline':
- from calibre.ebooks.htmlz.oeb2html import OEB2HTMLInlineCSSizer
+ from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTMLInlineCSSizer
OEB2HTMLizer = OEB2HTMLInlineCSSizer
elif opts.htmlz_css_type == 'tag':
- from calibre.ebooks.htmlz.oeb2html import OEB2HTMLNoCSSizer
+ from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTMLNoCSSizer
OEB2HTMLizer = OEB2HTMLNoCSSizer
else:
- from calibre.ebooks.htmlz.oeb2html import OEB2HTMLClassCSSizer as OEB2HTMLizer
+ from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTMLClassCSSizer as OEB2HTMLizer
with TemporaryDirectory(u'_htmlz_output') as tdir:
htmlizer = OEB2HTMLizer(log)
@@ -80,7 +80,7 @@ class HTMLZOutput(OutputFormatPlugin):
fname = u'index'
if opts.htmlz_title_filename:
- from calibre.utils.filenames import shorten_components_to
+ from ebook_converter.utils.filenames import shorten_components_to
fname = shorten_components_to(100, (ascii_filename(unicode_type(oeb_book.metadata.title[0])),))[0]
with open(os.path.join(tdir, fname+u'.html'), 'wb') as tf:
if isinstance(html, unicode_type):
@@ -115,7 +115,7 @@ class HTMLZOutput(OutputFormatPlugin):
term = oeb_book.metadata.cover[0].term
cover_data = oeb_book.guide[term].item.data
if cover_data:
- from calibre.utils.img import save_cover_data_to
+ from ebook_converter.utils.img import save_cover_data_to
cover_path = os.path.join(tdir, u'cover.jpg')
with lopen(cover_path, 'w') as cf:
cf.write('')
diff --git a/ebook_converter/ebooks/conversion/plugins/lit_input.py b/ebook_converter/ebooks/conversion/plugins/lit_input.py
index 96f1867..c424ea9 100644
--- a/ebook_converter/ebooks/conversion/plugins/lit_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/lit_input.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import InputFormatPlugin
+from ebook_converter.customize.conversion import InputFormatPlugin
class LITInput(InputFormatPlugin):
@@ -19,13 +19,13 @@ class LITInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.lit.reader import LitReader
- from calibre.ebooks.conversion.plumber import create_oebbook
+ from ebook_converter.ebooks.lit.reader import LitReader
+ from ebook_converter.ebooks.conversion.plumber import create_oebbook
self.log = log
return create_oebbook(log, stream, options, reader=LitReader)
def postprocess_book(self, oeb, opts, log):
- from calibre.ebooks.oeb.base import XHTML_NS, XPath, XHTML
+ from ebook_converter.ebooks.oeb.base import XHTML_NS, XPath, XHTML
for item in oeb.spine:
root = item.data
if not hasattr(root, 'xpath'):
@@ -40,10 +40,10 @@ class LITInput(InputFormatPlugin):
body = body[0]
if len(body) == 1 and body[0].tag == XHTML('pre'):
pre = body[0]
- from calibre.ebooks.txt.processor import convert_basic, \
+ from ebook_converter.ebooks.txt.processor import convert_basic, \
separate_paragraphs_single_line
- from calibre.ebooks.chardet import xml_to_unicode
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.chardet import xml_to_unicode
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
import copy
self.log('LIT file with all text in singe tag detected')
html = separate_paragraphs_single_line(pre.text)
@@ -53,7 +53,7 @@ class LITInput(InputFormatPlugin):
resolve_entities=True)[0]
if opts.smarten_punctuation:
# SmartyPants skips text inside tags
- from calibre.ebooks.conversion.preprocess import smarten_punctuation
+ from ebook_converter.ebooks.conversion.preprocess import smarten_punctuation
html = smarten_punctuation(html, self.log)
root = safe_xml_fromstring(html)
body = XPath('//h:body')(root)
diff --git a/ebook_converter/ebooks/conversion/plugins/lit_output.py b/ebook_converter/ebooks/conversion/plugins/lit_output.py
index a0d9a7f..e4e6711 100644
--- a/ebook_converter/ebooks/conversion/plugins/lit_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/lit_output.py
@@ -7,7 +7,7 @@ __copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import OutputFormatPlugin
+from ebook_converter.customize.conversion import OutputFormatPlugin
class LITOutput(OutputFormatPlugin):
@@ -19,11 +19,11 @@ class LITOutput(OutputFormatPlugin):
def convert(self, oeb, output_path, input_plugin, opts, log):
self.log, self.opts, self.oeb = log, opts, oeb
- from calibre.ebooks.oeb.transforms.manglecase import CaseMangler
- from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer
- from calibre.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder
- from calibre.ebooks.lit.writer import LitWriter
- from calibre.ebooks.oeb.transforms.split import Split
+ from ebook_converter.ebooks.oeb.transforms.manglecase import CaseMangler
+ from ebook_converter.ebooks.oeb.transforms.rasterize import SVGRasterizer
+ from ebook_converter.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder
+ from ebook_converter.ebooks.lit.writer import LitWriter
+ from ebook_converter.ebooks.oeb.transforms.split import Split
split = Split(split_on_page_breaks=True, max_flow_size=0,
remove_css_pagebreaks=False)
split(self.oeb, self.opts)
diff --git a/ebook_converter/ebooks/conversion/plugins/lrf_input.py b/ebook_converter/ebooks/conversion/plugins/lrf_input.py
index d40def2..78808f6 100644
--- a/ebook_converter/ebooks/conversion/plugins/lrf_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/lrf_input.py
@@ -7,7 +7,7 @@ __copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
import os, sys
-from calibre.customize.conversion import InputFormatPlugin
+from ebook_converter.customize.conversion import InputFormatPlugin
class LRFInput(InputFormatPlugin):
@@ -20,12 +20,12 @@ class LRFInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.lrf.input import (MediaType, Styles, TextBlock,
+ from ebook_converter.ebooks.lrf.input import (MediaType, Styles, TextBlock,
Canvas, ImageBlock, RuledLine)
self.log = log
self.log('Generating XML')
- from calibre.ebooks.lrf.lrfparser import LRFDocument
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.lrf.lrfparser import LRFDocument
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
from lxml import etree
d = LRFDocument(stream)
d.parse()
diff --git a/ebook_converter/ebooks/conversion/plugins/lrf_output.py b/ebook_converter/ebooks/conversion/plugins/lrf_output.py
index 947d30c..230d250 100644
--- a/ebook_converter/ebooks/conversion/plugins/lrf_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/lrf_output.py
@@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
import sys, os
-from calibre.customize.conversion import OutputFormatPlugin
-from calibre.customize.conversion import OptionRecommendation
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import OutputFormatPlugin
+from ebook_converter.customize.conversion import OptionRecommendation
+from ebook_converter.polyglot.builtins import unicode_type
class LRFOptions(object):
@@ -53,7 +53,7 @@ class LRFOptions(object):
self.use_spine = True
self.font_delta = 0
self.ignore_colors = False
- from calibre.ebooks.lrf import PRS500_PROFILE
+ from ebook_converter.ebooks.lrf import PRS500_PROFILE
self.profile = PRS500_PROFILE
self.link_levels = sys.maxsize
self.link_exclude = '@'
@@ -140,9 +140,9 @@ class LRFOutput(OutputFormatPlugin):
('change_justification', 'original', OptionRecommendation.HIGH)}
def convert_images(self, pages, opts, wide):
- from calibre.ebooks.lrf.pylrs.pylrs import Book, BookSetting, ImageStream, ImageBlock
+ from ebook_converter.ebooks.lrf.pylrs.pylrs import Book, BookSetting, ImageStream, ImageBlock
from uuid import uuid4
- from calibre.constants import __appname__, __version__
+ from ebook_converter.constants import __appname__, __version__
width, height = (784, 1012) if wide else (584, 754)
@@ -168,7 +168,7 @@ class LRFOutput(OutputFormatPlugin):
book.renderLrf(open(opts.output, 'wb'))
def flatten_toc(self):
- from calibre.ebooks.oeb.base import TOC
+ from ebook_converter.ebooks.oeb.base import TOC
nroot = TOC()
for x in self.oeb.toc.iterdescendants():
nroot.add(x.title, x.href)
@@ -186,11 +186,11 @@ class LRFOutput(OutputFormatPlugin):
self.flatten_toc()
- from calibre.ptempfile import TemporaryDirectory
+ from ebook_converter.ptempfile import TemporaryDirectory
with TemporaryDirectory('_lrf_output') as tdir:
- from calibre.customize.ui import plugin_for_output_format
+ from ebook_converter.customize.ui import plugin_for_output_format
oeb_output = plugin_for_output_format('oeb')
oeb_output.convert(oeb, tdir, input_plugin, opts, log)
opf = [x for x in os.listdir(tdir) if x.endswith('.opf')][0]
- from calibre.ebooks.lrf.html.convert_from import process_file
+ from ebook_converter.ebooks.lrf.html.convert_from import process_file
process_file(os.path.join(tdir, opf), lrf_opts, self.log)
diff --git a/ebook_converter/ebooks/conversion/plugins/mobi_input.py b/ebook_converter/ebooks/conversion/plugins/mobi_input.py
index 34e0f46..a84f5e7 100644
--- a/ebook_converter/ebooks/conversion/plugins/mobi_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/mobi_input.py
@@ -6,8 +6,8 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import unicode_type
class MOBIInput(InputFormatPlugin):
@@ -23,7 +23,7 @@ class MOBIInput(InputFormatPlugin):
self.is_kf8 = False
self.mobi_is_joint = False
- from calibre.ebooks.mobi.reader.mobi6 import MobiReader
+ from ebook_converter.ebooks.mobi.reader.mobi6 import MobiReader
from lxml import html
parse_cache = {}
try:
@@ -42,7 +42,7 @@ class MOBIInput(InputFormatPlugin):
log('Found KF8 MOBI of type %r'%mr.kf8_type)
if mr.kf8_type == 'joint':
self.mobi_is_joint = True
- from calibre.ebooks.mobi.reader.mobi8 import Mobi8Reader
+ from ebook_converter.ebooks.mobi.reader.mobi8 import Mobi8Reader
mr = Mobi8Reader(mr, log)
opf = os.path.abspath(mr())
self.encrypted_fonts = mr.encrypted_fonts
@@ -55,7 +55,7 @@ class MOBIInput(InputFormatPlugin):
raw = raw.encode('utf-8')
with lopen('debug-raw.html', 'wb') as f:
f.write(raw)
- from calibre.ebooks.oeb.base import close_self_closing_tags
+ from ebook_converter.ebooks.oeb.base import close_self_closing_tags
for f, root in parse_cache.items():
raw = html.tostring(root, encoding='utf-8', method='xml',
include_meta_content_type=False)
diff --git a/ebook_converter/ebooks/conversion/plugins/mobi_output.py b/ebook_converter/ebooks/conversion/plugins/mobi_output.py
index 28cff52..5fbb6e0 100644
--- a/ebook_converter/ebooks/conversion/plugins/mobi_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/mobi_output.py
@@ -6,13 +6,13 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import (OutputFormatPlugin,
+from ebook_converter.customize.conversion import (OutputFormatPlugin,
OptionRecommendation)
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
def remove_html_cover(oeb, log):
- from calibre.ebooks.oeb.base import OEB_DOCS
+ from ebook_converter.ebooks.oeb.base import OEB_DOCS
if not oeb.metadata.cover \
or 'cover' not in oeb.guide:
@@ -32,7 +32,7 @@ def remove_html_cover(oeb, log):
def extract_mobi(output_path, opts):
if opts.extract_to is not None:
- from calibre.ebooks.mobi.debug.main import inspect_mobi
+ from ebook_converter.ebooks.mobi.debug.main import inspect_mobi
ddir = opts.extract_to
inspect_mobi(output_path, ddir=ddir)
@@ -120,7 +120,7 @@ class MOBIOutput(OutputFormatPlugin):
def check_for_masthead(self):
found = 'masthead' in self.oeb.guide
if not found:
- from calibre.ebooks import generate_masthead
+ from ebook_converter.ebooks import generate_masthead
self.oeb.log.debug('No masthead found in manifest, generating default mastheadImage...')
raw = generate_masthead(unicode_type(self.oeb.metadata['title'][0]))
id, href = self.oeb.manifest.generate('masthead', 'masthead')
@@ -130,7 +130,7 @@ class MOBIOutput(OutputFormatPlugin):
self.oeb.log.debug('Using mastheadImage supplied in manifest...')
def periodicalize_toc(self):
- from calibre.ebooks.oeb.base import TOC
+ from ebook_converter.ebooks.oeb.base import TOC
toc = self.oeb.toc
if not toc or len(self.oeb.spine) < 3:
return
@@ -183,7 +183,7 @@ class MOBIOutput(OutputFormatPlugin):
toc.nodes[0].href = toc.nodes[0].nodes[0].href
def convert(self, oeb, output_path, input_plugin, opts, log):
- from calibre.ebooks.mobi.writer2.resources import Resources
+ from ebook_converter.ebooks.mobi.writer2.resources import Resources
self.log, self.opts, self.oeb = log, opts, oeb
mobi_type = opts.mobi_file_type
@@ -197,10 +197,10 @@ class MOBIOutput(OutputFormatPlugin):
self.check_for_periodical()
if create_kf8:
- from calibre.ebooks.mobi.writer8.cleanup import remove_duplicate_anchors
+ from ebook_converter.ebooks.mobi.writer8.cleanup import remove_duplicate_anchors
remove_duplicate_anchors(self.oeb)
# Split on pagebreaks so that the resulting KF8 is faster to load
- from calibre.ebooks.oeb.transforms.split import Split
+ from ebook_converter.ebooks.oeb.transforms.split import Split
Split()(self.oeb, self.opts)
kf8 = self.create_kf8(resources, for_joint=mobi_type=='both'
@@ -214,16 +214,16 @@ class MOBIOutput(OutputFormatPlugin):
self.write_mobi(input_plugin, output_path, kf8, resources)
def create_kf8(self, resources, for_joint=False):
- from calibre.ebooks.mobi.writer8.main import create_kf8_book
+ from ebook_converter.ebooks.mobi.writer8.main import create_kf8_book
return create_kf8_book(self.oeb, self.opts, resources,
for_joint=for_joint)
def write_mobi(self, input_plugin, output_path, kf8, resources):
- from calibre.ebooks.mobi.mobiml import MobiMLizer
- from calibre.ebooks.oeb.transforms.manglecase import CaseMangler
- from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
- from calibre.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.ebooks.mobi.mobiml import MobiMLizer
+ from ebook_converter.ebooks.oeb.transforms.manglecase import CaseMangler
+ from ebook_converter.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
+ from ebook_converter.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder
+ from ebook_converter.customize.ui import plugin_for_input_format
opts, oeb = self.opts, self.oeb
if not opts.no_inline_toc:
@@ -245,20 +245,20 @@ class MOBIOutput(OutputFormatPlugin):
mobimlizer = MobiMLizer(ignore_tables=opts.linearize_tables)
mobimlizer(oeb, opts)
write_page_breaks_after_item = input_plugin is not plugin_for_input_format('cbz')
- from calibre.ebooks.mobi.writer2.main import MobiWriter
+ from ebook_converter.ebooks.mobi.writer2.main import MobiWriter
writer = MobiWriter(opts, resources, kf8,
write_page_breaks_after_item=write_page_breaks_after_item)
writer(oeb, output_path)
extract_mobi(output_path, opts)
def specialize_css_for_output(self, log, opts, item, stylizer):
- from calibre.ebooks.mobi.writer8.cleanup import CSSCleanup
+ from ebook_converter.ebooks.mobi.writer8.cleanup import CSSCleanup
CSSCleanup(log, opts)(item, stylizer)
def workaround_fire_bugs(self, jacket):
# The idiotic Fire crashes when trying to render the table used to
# layout the jacket
- from calibre.ebooks.oeb.base import XHTML
+ from ebook_converter.ebooks.oeb.base import XHTML
for table in jacket.data.xpath('//*[local-name()="table"]'):
table.tag = XHTML('div')
for tr in table.xpath('descendant::*[local-name()="tr"]'):
@@ -309,9 +309,9 @@ class AZW3Output(OutputFormatPlugin):
}
def convert(self, oeb, output_path, input_plugin, opts, log):
- from calibre.ebooks.mobi.writer2.resources import Resources
- from calibre.ebooks.mobi.writer8.main import create_kf8_book
- from calibre.ebooks.mobi.writer8.cleanup import remove_duplicate_anchors
+ from ebook_converter.ebooks.mobi.writer2.resources import Resources
+ from ebook_converter.ebooks.mobi.writer8.main import create_kf8_book
+ from ebook_converter.ebooks.mobi.writer8.cleanup import remove_duplicate_anchors
self.oeb, self.opts, self.log = oeb, opts, log
opts.mobi_periodical = self.is_periodical
@@ -324,7 +324,7 @@ class AZW3Output(OutputFormatPlugin):
remove_html_cover(self.oeb, self.log)
# Split on pagebreaks so that the resulting KF8 is faster to load
- from calibre.ebooks.oeb.transforms.split import Split
+ from ebook_converter.ebooks.oeb.transforms.split import Split
Split()(self.oeb, self.opts)
kf8 = create_kf8_book(self.oeb, self.opts, resources, for_joint=False)
@@ -333,5 +333,5 @@ class AZW3Output(OutputFormatPlugin):
extract_mobi(output_path, opts)
def specialize_css_for_output(self, log, opts, item, stylizer):
- from calibre.ebooks.mobi.writer8.cleanup import CSSCleanup
+ from ebook_converter.ebooks.mobi.writer8.cleanup import CSSCleanup
CSSCleanup(log, opts)(item, stylizer)
diff --git a/ebook_converter/ebooks/conversion/plugins/odt_input.py b/ebook_converter/ebooks/conversion/plugins/odt_input.py
index f2f045b..8c9d791 100644
--- a/ebook_converter/ebooks/conversion/plugins/odt_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/odt_input.py
@@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
Convert an ODT file into a Open Ebook
'''
-from calibre.customize.conversion import InputFormatPlugin
+from ebook_converter.customize.conversion import InputFormatPlugin
class ODTInput(InputFormatPlugin):
@@ -21,5 +21,5 @@ class ODTInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.odt.input import Extract
+ from ebook_converter.ebooks.odt.input import Extract
return Extract()(stream, '.', log)
diff --git a/ebook_converter/ebooks/conversion/plugins/oeb_output.py b/ebook_converter/ebooks/conversion/plugins/oeb_output.py
index df1aa4e..0b012c9 100644
--- a/ebook_converter/ebooks/conversion/plugins/oeb_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/oeb_output.py
@@ -7,9 +7,9 @@ __docformat__ = 'restructuredtext en'
import os, re
-from calibre.customize.conversion import (OutputFormatPlugin,
+from ebook_converter.customize.conversion import (OutputFormatPlugin,
OptionRecommendation)
-from calibre import CurrentDir
+from ebook_converter import CurrentDir
class OEBOutput(OutputFormatPlugin):
@@ -22,14 +22,14 @@ class OEBOutput(OutputFormatPlugin):
recommendations = {('pretty_print', True, OptionRecommendation.HIGH)}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from polyglot.urllib import unquote
+ from ebook_converter.polyglot.urllib import unquote
from lxml import etree
self.log, self.opts = log, opts
if not os.path.exists(output_path):
os.makedirs(output_path)
- from calibre.ebooks.oeb.base import OPF_MIME, NCX_MIME, PAGE_MAP_MIME, OEB_STYLES
- from calibre.ebooks.oeb.normalize_css import condense_sheet
+ from ebook_converter.ebooks.oeb.base import OPF_MIME, NCX_MIME, PAGE_MAP_MIME, OEB_STYLES
+ from ebook_converter.ebooks.oeb.normalize_css import condense_sheet
with CurrentDir(output_path):
results = oeb_book.to_opf2(page_map=True)
for key in (OPF_MIME, NCX_MIME, PAGE_MAP_MIME):
@@ -89,7 +89,7 @@ class OEBOutput(OutputFormatPlugin):
self.log.warn('The cover image has an id != "cover". Renaming'
' to work around bug in Nook Color')
- from calibre.ebooks.oeb.base import uuid_id
+ from ebook_converter.ebooks.oeb.base import uuid_id
newid = uuid_id()
for item in manifest_items_with_id('cover'):
@@ -114,7 +114,7 @@ class OEBOutput(OutputFormatPlugin):
# }}}
def migrate_lang_code(self, root): # {{{
- from calibre.utils.localization import lang_as_iso639_1
+ from ebook_converter.utils.localization import lang_as_iso639_1
for lang in root.xpath('//*[local-name() = "language"]'):
clc = lang_as_iso639_1(lang.text)
if clc:
diff --git a/ebook_converter/ebooks/conversion/plugins/pdb_input.py b/ebook_converter/ebooks/conversion/plugins/pdb_input.py
index a55a4ff..eff0eb3 100644
--- a/ebook_converter/ebooks/conversion/plugins/pdb_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/pdb_input.py
@@ -5,8 +5,8 @@ __license__ = 'GPL v3'
__copyright__ = '2009, John Schember '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import getcwd
class PDBInput(InputFormatPlugin):
@@ -19,8 +19,8 @@ class PDBInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.pdb.header import PdbHeaderReader
- from calibre.ebooks.pdb import PDBError, IDENTITY_TO_NAME, get_reader
+ from ebook_converter.ebooks.pdb.header import PdbHeaderReader
+ from ebook_converter.ebooks.pdb import PDBError, IDENTITY_TO_NAME, get_reader
header = PdbHeaderReader(stream)
Reader = get_reader(header.ident)
diff --git a/ebook_converter/ebooks/conversion/plugins/pdb_output.py b/ebook_converter/ebooks/conversion/plugins/pdb_output.py
index ec03e97..3b423a3 100644
--- a/ebook_converter/ebooks/conversion/plugins/pdb_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/pdb_output.py
@@ -7,9 +7,9 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin, \
+from ebook_converter.customize.conversion import OutputFormatPlugin, \
OptionRecommendation
-from calibre.ebooks.pdb import PDBError, get_writer, ALL_FORMAT_WRITERS
+from ebook_converter.ebooks.pdb import PDBError, get_writer, ALL_FORMAT_WRITERS
class PDBOutput(OutputFormatPlugin):
diff --git a/ebook_converter/ebooks/conversion/plugins/pdf_input.py b/ebook_converter/ebooks/conversion/plugins/pdf_input.py
index f5eab98..3dd2f03 100644
--- a/ebook_converter/ebooks/conversion/plugins/pdf_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/pdf_input.py
@@ -7,8 +7,8 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from polyglot.builtins import as_bytes, getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.polyglot.builtins import as_bytes, getcwd
class PDFInput(InputFormatPlugin):
@@ -31,9 +31,9 @@ class PDFInput(InputFormatPlugin):
}
def convert_new(self, stream, accelerators):
- from calibre.ebooks.pdf.pdftohtml import pdftohtml
- from calibre.utils.cleantext import clean_ascii_chars
- from calibre.ebooks.pdf.reflow import PDFDocument
+ from ebook_converter.ebooks.pdf.pdftohtml import pdftohtml
+ from ebook_converter.utils.cleantext import clean_ascii_chars
+ from ebook_converter.ebooks.pdf.reflow import PDFDocument
pdftohtml(getcwd(), stream.name, self.opts.no_images, as_xml=True)
with lopen('index.xml', 'rb') as f:
@@ -43,8 +43,8 @@ class PDFInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.metadata.opf2 import OPFCreator
- from calibre.ebooks.pdf.pdftohtml import pdftohtml
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.ebooks.pdf.pdftohtml import pdftohtml
log.debug('Converting file to html...')
# The main html file will be named index.html
@@ -53,7 +53,7 @@ class PDFInput(InputFormatPlugin):
return self.convert_new(stream, accelerators)
pdftohtml(getcwd(), stream.name, options.no_images)
- from calibre.ebooks.metadata.meta import get_metadata
+ from ebook_converter.ebooks.metadata.meta import get_metadata
log.debug('Retrieving document metadata...')
mi = get_metadata(stream, 'pdf')
opf = OPFCreator(getcwd(), mi)
diff --git a/ebook_converter/ebooks/conversion/plugins/pdf_output.py b/ebook_converter/ebooks/conversion/plugins/pdf_output.py
index 8197128..ec08ede 100644
--- a/ebook_converter/ebooks/conversion/plugins/pdf_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/pdf_output.py
@@ -11,10 +11,10 @@ Convert OEB ebook format to PDF.
import glob, os
-from calibre.customize.conversion import (OutputFormatPlugin,
+from ebook_converter.customize.conversion import (OutputFormatPlugin,
OptionRecommendation)
-from calibre.ptempfile import TemporaryDirectory
-from polyglot.builtins import iteritems, unicode_type
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.polyglot.builtins import iteritems, unicode_type
UNITS = ('millimeter', 'centimeter', 'point', 'inch' , 'pica' , 'didot',
'cicero', 'devicepixel')
@@ -150,8 +150,8 @@ class PDFOutput(OutputFormatPlugin):
# that hopefully no Qt application has been constructed as yet
from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
from PyQt5.QtWebEngineWidgets import QWebEnginePage # noqa
- from calibre.gui2 import must_use_qt
- from calibre.constants import FAKE_PROTOCOL
+ from ebook_converter.gui2 import must_use_qt
+ from ebook_converter.constants import FAKE_PROTOCOL
scheme = QWebEngineUrlScheme(FAKE_PROTOCOL.encode('ascii'))
scheme.setSyntax(QWebEngineUrlScheme.Syntax.Host)
scheme.setFlags(QWebEngineUrlScheme.SecureScheme)
@@ -169,13 +169,13 @@ class PDFOutput(OutputFormatPlugin):
self.oeb = oeb_book
self.input_plugin, self.opts, self.log = input_plugin, opts, log
self.output_path = output_path
- from calibre.ebooks.oeb.base import OPF, OPF2_NS
+ from ebook_converter.ebooks.oeb.base import OPF, OPF2_NS
from lxml import etree
from io import BytesIO
package = etree.Element(OPF('package'),
attrib={'version': '2.0', 'unique-identifier': 'dummy'},
nsmap={None: OPF2_NS})
- from calibre.ebooks.metadata.opf2 import OPF
+ from ebook_converter.ebooks.metadata.opf2 import OPF
self.oeb.metadata.to_opf2(package)
self.metadata = OPF(BytesIO(etree.tostring(package))).to_book_metadata()
self.cover_data = None
@@ -188,7 +188,7 @@ class PDFOutput(OutputFormatPlugin):
self.convert_text(oeb_book)
def convert_images(self, images):
- from calibre.ebooks.pdf.image_writer import convert
+ from ebook_converter.ebooks.pdf.image_writer import convert
convert(images, self.output_path, self.opts, self.metadata, self.report_progress)
def get_cover_data(self):
@@ -200,8 +200,8 @@ class PDFOutput(OutputFormatPlugin):
def process_fonts(self):
''' Make sure all fonts are embeddable '''
- from calibre.ebooks.oeb.base import urlnormalize
- from calibre.utils.fonts.utils import remove_embed_restriction
+ from ebook_converter.ebooks.oeb.base import urlnormalize
+ from ebook_converter.utils.fonts.utils import remove_embed_restriction
processed = set()
for item in list(self.oeb.manifest):
@@ -232,7 +232,7 @@ class PDFOutput(OutputFormatPlugin):
def convert_text(self, oeb_book):
import json
- from calibre.ebooks.pdf.html_writer import convert
+ from ebook_converter.ebooks.pdf.html_writer import convert
self.get_cover_data()
self.process_fonts()
@@ -245,7 +245,7 @@ class PDFOutput(OutputFormatPlugin):
root.set('data-calibre-pdf-output-page-margins', json.dumps(margins))
with TemporaryDirectory('_pdf_out') as oeb_dir:
- from calibre.customize.ui import plugin_for_output_format
+ from ebook_converter.customize.ui import plugin_for_output_format
oeb_dir = os.path.realpath(oeb_dir)
oeb_output = plugin_for_output_format('oeb')
oeb_output.convert(oeb_book, oeb_dir, self.input_plugin, self.opts, self.log)
diff --git a/ebook_converter/ebooks/conversion/plugins/pml_input.py b/ebook_converter/ebooks/conversion/plugins/pml_input.py
index 927b774..4384911 100644
--- a/ebook_converter/ebooks/conversion/plugins/pml_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/pml_input.py
@@ -9,9 +9,9 @@ import glob
import os
import shutil
-from calibre.customize.conversion import InputFormatPlugin
-from calibre.ptempfile import TemporaryDirectory
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.polyglot.builtins import getcwd
class PMLInput(InputFormatPlugin):
@@ -24,7 +24,7 @@ class PMLInput(InputFormatPlugin):
commit_name = 'pml_input'
def process_pml(self, pml_path, html_path, close_all=False):
- from calibre.ebooks.pml.pmlconverter import PML_HTMLizer
+ from ebook_converter.ebooks.pml.pmlconverter import PML_HTMLizer
pclose = False
hclose = False
@@ -89,9 +89,9 @@ class PMLInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.metadata.toc import TOC
- from calibre.ebooks.metadata.opf2 import OPFCreator
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.metadata.toc import TOC
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.utils.zipfile import ZipFile
self.options = options
self.log = log
@@ -128,7 +128,7 @@ class PMLInput(InputFormatPlugin):
for item in pages+images:
manifest_items.append((item, None))
- from calibre.ebooks.metadata.meta import get_metadata
+ from ebook_converter.ebooks.metadata.meta import get_metadata
log.debug('Reading metadata from input file...')
mi = get_metadata(stream, 'pml')
if 'images/cover.png' in images:
@@ -145,7 +145,7 @@ class PMLInput(InputFormatPlugin):
return os.path.join(getcwd(), 'metadata.opf')
def postprocess_book(self, oeb, opts, log):
- from calibre.ebooks.oeb.base import XHTML, barename
+ from ebook_converter.ebooks.oeb.base import XHTML, barename
for item in oeb.spine:
if hasattr(item.data, 'xpath'):
for heading in item.data.iterdescendants(*map(XHTML, 'h1 h2 h3 h4 h5 h6'.split())):
diff --git a/ebook_converter/ebooks/conversion/plugins/pml_output.py b/ebook_converter/ebooks/conversion/plugins/pml_output.py
index 2876c07..798122e 100644
--- a/ebook_converter/ebooks/conversion/plugins/pml_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/pml_output.py
@@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
import os, io
-from calibre.customize.conversion import (OutputFormatPlugin,
+from ebook_converter.customize.conversion import (OutputFormatPlugin,
OptionRecommendation)
-from calibre.ptempfile import TemporaryDirectory
-from polyglot.builtins import unicode_type
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.polyglot.builtins import unicode_type
class PMLOutput(OutputFormatPlugin):
@@ -37,8 +37,8 @@ class PMLOutput(OutputFormatPlugin):
}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.pml.pmlml import PMLMLizer
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.pml.pmlml import PMLMLizer
+ from ebook_converter.utils.zipfile import ZipFile
with TemporaryDirectory('_pmlz_output') as tdir:
pmlmlizer = PMLMLizer(log)
@@ -58,7 +58,7 @@ class PMLOutput(OutputFormatPlugin):
def write_images(self, manifest, image_hrefs, out_dir, opts):
from PIL import Image
- from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
+ from ebook_converter.ebooks.oeb.base import OEB_RASTER_IMAGES
for item in manifest:
if item.media_type in OEB_RASTER_IMAGES and item.href in image_hrefs.keys():
if opts.full_image_depth:
diff --git a/ebook_converter/ebooks/conversion/plugins/rb_input.py b/ebook_converter/ebooks/conversion/plugins/rb_input.py
index f8a0377..c541eac 100644
--- a/ebook_converter/ebooks/conversion/plugins/rb_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/rb_input.py
@@ -6,8 +6,8 @@ __copyright__ = '2009, John Schember '
__docformat__ = 'restructuredtext en'
-from calibre.customize.conversion import InputFormatPlugin
-from polyglot.builtins import getcwd
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.polyglot.builtins import getcwd
class RBInput(InputFormatPlugin):
@@ -20,7 +20,7 @@ class RBInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.rb.reader import Reader
+ from ebook_converter.ebooks.rb.reader import Reader
reader = Reader(stream, log, options.input_encoding)
opf = reader.extract_content(getcwd())
diff --git a/ebook_converter/ebooks/conversion/plugins/rb_output.py b/ebook_converter/ebooks/conversion/plugins/rb_output.py
index 4ddfd29..be8f935 100644
--- a/ebook_converter/ebooks/conversion/plugins/rb_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/rb_output.py
@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
+from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation
class RBOutput(OutputFormatPlugin):
@@ -23,7 +23,7 @@ class RBOutput(OutputFormatPlugin):
help=_('Add Table of Contents to beginning of the book.'))}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.rb.writer import RBWriter
+ from ebook_converter.ebooks.rb.writer import RBWriter
close = False
if not hasattr(output_path, 'write'):
diff --git a/ebook_converter/ebooks/conversion/plugins/recipe_input.py b/ebook_converter/ebooks/conversion/plugins/recipe_input.py
index f616a72..ae78dd0 100644
--- a/ebook_converter/ebooks/conversion/plugins/recipe_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/recipe_input.py
@@ -8,10 +8,10 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from calibre.constants import numeric_version
-from calibre import walk
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.constants import numeric_version
+from ebook_converter import walk
+from ebook_converter.polyglot.builtins import unicode_type
class RecipeDisabled(Exception):
@@ -58,10 +58,10 @@ class RecipeInput(InputFormatPlugin):
def convert(self, recipe_or_file, opts, file_ext, log,
accelerators):
- from calibre.web.feeds.recipes import compile_recipe
+ from ebook_converter.web.feeds.recipes import compile_recipe
opts.output_profile.flow_size = 0
if file_ext == 'downloaded_recipe':
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
zf = ZipFile(recipe_or_file, 'r')
zf.extractall()
zf.close()
@@ -72,7 +72,7 @@ class RecipeInput(InputFormatPlugin):
self.recipe_object = recipe(opts, log, self.report_progress)
else:
if os.environ.get('CALIBRE_RECIPE_URN'):
- from calibre.web.feeds.recipes.collection import get_custom_recipe, get_builtin_recipe_by_id
+ from ebook_converter.web.feeds.recipes.collection import get_custom_recipe, get_builtin_recipe_by_id
urn = os.environ['CALIBRE_RECIPE_URN']
log('Downloading recipe urn: ' + urn)
rtype, recipe_id = urn.partition(':')[::2]
@@ -93,7 +93,7 @@ class RecipeInput(InputFormatPlugin):
recipe = compile_recipe(self.recipe_source)
log('Using custom recipe')
else:
- from calibre.web.feeds.recipes.collection import (
+ from ebook_converter.web.feeds.recipes.collection import (
get_builtin_recipe_by_title, get_builtin_recipe_titles)
title = getattr(opts, 'original_recipe_input_arg', recipe_or_file)
title = os.path.basename(title).rpartition('.')[0]
@@ -157,7 +157,7 @@ class RecipeInput(InputFormatPlugin):
def specialize(self, oeb, opts, log, output_fmt):
if opts.no_inline_navbars:
- from calibre.ebooks.oeb.base import XPath
+ from ebook_converter.ebooks.oeb.base import XPath
for item in oeb.spine:
for div in XPath('//h:div[contains(@class, "calibre_navbar")]')(item.data):
div.getparent().remove(div)
diff --git a/ebook_converter/ebooks/conversion/plugins/rtf_input.py b/ebook_converter/ebooks/conversion/plugins/rtf_input.py
index 952898d..3917335 100644
--- a/ebook_converter/ebooks/conversion/plugins/rtf_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/rtf_input.py
@@ -4,8 +4,8 @@ __copyright__ = '2008, Kovid Goyal '
import os, glob, re, textwrap
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from polyglot.builtins import iteritems, filter, getcwd, as_bytes
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.polyglot.builtins import iteritems, filter, getcwd, as_bytes
border_style_map = {
'single' : 'solid',
@@ -53,7 +53,7 @@ class RTFInput(InputFormatPlugin):
}
def generate_xml(self, stream):
- from calibre.ebooks.rtf2xml.ParseRtf import ParseRtf
+ from ebook_converter.ebooks.rtf2xml.ParseRtf import ParseRtf
ofile = u'dataxml.xml'
run_lev, debug_dir, indent_out = 1, None, 0
if getattr(self.opts, 'debug_pipeline', None) is not None:
@@ -117,7 +117,7 @@ class RTFInput(InputFormatPlugin):
return f.read()
def extract_images(self, picts):
- from calibre.utils.imghdr import what
+ from ebook_converter.utils.imghdr import what
from binascii import unhexlify
self.log('Extracting images...')
@@ -167,7 +167,7 @@ class RTFInput(InputFormatPlugin):
if self.opts.ignore_wmf:
os.remove(name)
return '__REMOVE_ME__'
- from calibre.ebooks.covers import message_image
+ from ebook_converter.ebooks.covers import message_image
if self.default_img is None:
self.default_img = message_image('Conversion of WMF images is not supported.'
' Use Microsoft Word or OpenOffice to save this RTF file'
@@ -178,7 +178,7 @@ class RTFInput(InputFormatPlugin):
return name
def rasterize_wmf(self, name):
- from calibre.utils.wmf.parse import wmf_unwrap
+ from ebook_converter.utils.wmf.parse import wmf_unwrap
with open(name, 'rb') as f:
data = f.read()
data = wmf_unwrap(data)
@@ -247,11 +247,11 @@ class RTFInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
from lxml import etree
- from calibre.ebooks.metadata.meta import get_metadata
- from calibre.ebooks.metadata.opf2 import OPFCreator
- from calibre.ebooks.rtf2xml.ParseRtf import RtfInvalidCodeException
- from calibre.ebooks.rtf.input import InlineClass
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.metadata.meta import get_metadata
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.ebooks.rtf2xml.ParseRtf import RtfInvalidCodeException
+ from ebook_converter.ebooks.rtf.input import InlineClass
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
self.opts = options
self.log = log
self.log('Converting RTF to XML...')
diff --git a/ebook_converter/ebooks/conversion/plugins/rtf_output.py b/ebook_converter/ebooks/conversion/plugins/rtf_output.py
index bafb67c..c2079ad 100644
--- a/ebook_converter/ebooks/conversion/plugins/rtf_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/rtf_output.py
@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin
+from ebook_converter.customize.conversion import OutputFormatPlugin
class RTFOutput(OutputFormatPlugin):
@@ -18,7 +18,7 @@ class RTFOutput(OutputFormatPlugin):
commit_name = 'rtf_output'
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.rtf.rtfml import RTFMLizer
+ from ebook_converter.ebooks.rtf.rtfml import RTFMLizer
rtfmlitzer = RTFMLizer(log)
content = rtfmlitzer.extract_content(oeb_book, opts)
diff --git a/ebook_converter/ebooks/conversion/plugins/snb_input.py b/ebook_converter/ebooks/conversion/plugins/snb_input.py
index 23ac302..8c44eac 100644
--- a/ebook_converter/ebooks/conversion/plugins/snb_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/snb_input.py
@@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import InputFormatPlugin
-from calibre.ptempfile import TemporaryDirectory
-from calibre.utils.filenames import ascii_filename
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import InputFormatPlugin
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.utils.filenames import ascii_filename
+from ebook_converter.polyglot.builtins import unicode_type
HTML_TEMPLATE = '%s\n%s\n'
@@ -33,9 +33,9 @@ class SNBInput(InputFormatPlugin):
accelerators):
import uuid
- from calibre.ebooks.oeb.base import DirContainer
- from calibre.ebooks.snb.snbfile import SNBFile
- from calibre.utils.xml_parse import safe_xml_fromstring
+ from ebook_converter.ebooks.oeb.base import DirContainer
+ from ebook_converter.ebooks.snb.snbfile import SNBFile
+ from ebook_converter.utils.xml_parse import safe_xml_fromstring
log.debug("Parsing SNB file...")
snbFile = SNBFile()
@@ -47,7 +47,7 @@ class SNBInput(InputFormatPlugin):
log.debug("Invalid SNB file")
raise ValueError("Invalid SNB file")
log.debug("Handle meta data ...")
- from calibre.ebooks.conversion.plumber import create_oebbook
+ from ebook_converter.ebooks.conversion.plumber import create_oebbook
oeb = create_oebbook(log, None, options,
encoding=options.input_encoding, populate=False)
meta = snbFile.GetFileStream('snbf/book.snbf')
diff --git a/ebook_converter/ebooks/conversion/plugins/snb_output.py b/ebook_converter/ebooks/conversion/plugins/snb_output.py
index 460e806..7abef66 100644
--- a/ebook_converter/ebooks/conversion/plugins/snb_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/snb_output.py
@@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
-from calibre.ptempfile import TemporaryDirectory
-from calibre.constants import __appname__, __version__
-from polyglot.builtins import unicode_type
+from ebook_converter.customize.conversion import OutputFormatPlugin, OptionRecommendation
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.constants import __appname__, __version__
+from ebook_converter.polyglot.builtins import unicode_type
class SNBOutput(OutputFormatPlugin):
@@ -51,11 +51,11 @@ class SNBOutput(OutputFormatPlugin):
def convert(self, oeb_book, output_path, input_plugin, opts, log):
from lxml import etree
- from calibre.ebooks.snb.snbfile import SNBFile
- from calibre.ebooks.snb.snbml import SNBMLizer, ProcessFileName
+ from ebook_converter.ebooks.snb.snbfile import SNBFile
+ from ebook_converter.ebooks.snb.snbml import SNBMLizer, ProcessFileName
self.opts = opts
- from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
+ from ebook_converter.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
try:
rasterizer = SVGRasterizer()
rasterizer(oeb_book, opts)
@@ -176,7 +176,7 @@ class SNBOutput(OutputFormatPlugin):
mergeLast = False
lastName = None
for item in s:
- from calibre.ebooks.oeb.base import OEB_DOCS, OEB_IMAGES
+ from ebook_converter.ebooks.oeb.base import OEB_DOCS, OEB_IMAGES
if m.hrefs[item.href].media_type in OEB_DOCS:
if item.href not in outputFiles:
log.debug('File %s is unused in TOC. Continue in last chapter' % item.href)
@@ -225,7 +225,7 @@ class SNBOutput(OutputFormatPlugin):
snbFile.Output(output_path)
def HandleImage(self, imageData, imagePath):
- from calibre.utils.img import image_from_data, resize_image, image_to_data
+ from ebook_converter.utils.img import image_from_data, resize_image, image_to_data
img = image_from_data(imageData)
x, y = img.width(), img.height()
if self.opts:
@@ -250,10 +250,10 @@ class SNBOutput(OutputFormatPlugin):
if __name__ == '__main__':
- from calibre.ebooks.oeb.reader import OEBReader
- from calibre.ebooks.oeb.base import OEBBook
- from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
- from calibre.customize.profiles import HanlinV3Output
+ from ebook_converter.ebooks.oeb.reader import OEBReader
+ from ebook_converter.ebooks.oeb.base import OEBBook
+ from ebook_converter.ebooks.conversion.preprocess import HTMLPreProcessor
+ from ebook_converter.customize.profiles import HanlinV3Output
class OptionValues(object):
pass
@@ -262,7 +262,7 @@ if __name__ == '__main__':
opts.output_profile = HanlinV3Output(None)
html_preprocessor = HTMLPreProcessor(None, None, opts)
- from calibre.utils.logging import default_log
+ from ebook_converter.utils.logging import default_log
oeb = OEBBook(default_log, html_preprocessor)
reader = OEBReader
reader()(oeb, '/tmp/bbb/processed/')
diff --git a/ebook_converter/ebooks/conversion/plugins/tcr_input.py b/ebook_converter/ebooks/conversion/plugins/tcr_input.py
index e996715..3f1ef11 100644
--- a/ebook_converter/ebooks/conversion/plugins/tcr_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/tcr_input.py
@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
from io import BytesIO
-from calibre.customize.conversion import InputFormatPlugin
+from ebook_converter.customize.conversion import InputFormatPlugin
class TCRInput(InputFormatPlugin):
@@ -19,7 +19,7 @@ class TCRInput(InputFormatPlugin):
commit_name = 'tcr_input'
def convert(self, stream, options, file_ext, log, accelerators):
- from calibre.ebooks.compression.tcr import decompress
+ from ebook_converter.ebooks.compression.tcr import decompress
log.info('Decompressing text...')
raw_txt = decompress(stream)
@@ -27,7 +27,7 @@ class TCRInput(InputFormatPlugin):
log.info('Converting text to OEB...')
stream = BytesIO(raw_txt)
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for opt in txt_plugin.options:
diff --git a/ebook_converter/ebooks/conversion/plugins/tcr_output.py b/ebook_converter/ebooks/conversion/plugins/tcr_output.py
index a49627f..56759f2 100644
--- a/ebook_converter/ebooks/conversion/plugins/tcr_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/tcr_output.py
@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.customize.conversion import OutputFormatPlugin, \
+from ebook_converter.customize.conversion import OutputFormatPlugin, \
OptionRecommendation
@@ -25,8 +25,8 @@ class TCROutput(OutputFormatPlugin):
'The default is utf-8.'))}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.txt.txtml import TXTMLizer
- from calibre.ebooks.compression.tcr import compress
+ from ebook_converter.ebooks.txt.txtml import TXTMLizer
+ from ebook_converter.ebooks.compression.tcr import compress
close = False
if not hasattr(output_path, 'write'):
diff --git a/ebook_converter/ebooks/conversion/plugins/txt_input.py b/ebook_converter/ebooks/conversion/plugins/txt_input.py
index ded07e0..579bcb1 100644
--- a/ebook_converter/ebooks/conversion/plugins/txt_input.py
+++ b/ebook_converter/ebooks/conversion/plugins/txt_input.py
@@ -7,9 +7,9 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre import _ent_pat, walk, xml_entity_to_unicode
-from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
-from polyglot.builtins import getcwd
+from ebook_converter import _ent_pat, walk, xml_entity_to_unicode
+from ebook_converter.customize.conversion import InputFormatPlugin, OptionRecommendation
+from ebook_converter.polyglot.builtins import getcwd
MD_EXTENSIONS = {
'abbr': _('Abbreviations'),
@@ -129,10 +129,10 @@ class TXTInput(InputFormatPlugin):
def convert(self, stream, options, file_ext, log,
accelerators):
- from calibre.ebooks.conversion.preprocess import DocAnalysis, Dehyphenator
- from calibre.ebooks.chardet import detect
- from calibre.utils.zipfile import ZipFile
- from calibre.ebooks.txt.processor import (convert_basic,
+ from ebook_converter.ebooks.conversion.preprocess import DocAnalysis, Dehyphenator
+ from ebook_converter.ebooks.chardet import detect
+ from ebook_converter.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.txt.processor import (convert_basic,
convert_markdown_with_metadata, separate_paragraphs_single_line,
separate_paragraphs_print_formatted, preserve_spaces,
detect_paragraph_type, detect_formatting_type,
@@ -225,7 +225,7 @@ class TXTInput(InputFormatPlugin):
txt = separate_paragraphs_print_formatted(txt)
txt = block_to_single_line(txt)
elif options.paragraph_type == 'unformatted':
- from calibre.ebooks.conversion.utils import HeuristicProcessor
+ from ebook_converter.ebooks.conversion.utils import HeuristicProcessor
# unwrap lines based on punctuation
docanalysis = DocAnalysis('txt', txt)
length = docanalysis.line_length(.5)
@@ -275,7 +275,7 @@ class TXTInput(InputFormatPlugin):
html = convert_basic(txt, epub_split_size_kb=flow_size)
# Run the HTMLized text through the html processing plugin.
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
html_input = plugin_for_input_format('html')
for opt in html_input.options:
setattr(options, opt.option.name, opt.recommended_value)
@@ -292,9 +292,9 @@ class TXTInput(InputFormatPlugin):
# Set metadata from file.
if input_mi is None:
- from calibre.customize.ui import get_file_type_metadata
+ from ebook_converter.customize.ui import get_file_type_metadata
input_mi = get_file_type_metadata(stream, file_ext)
- from calibre.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
+ from ebook_converter.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
meta_info_to_oeb_metadata(input_mi, oeb.metadata, log)
self.html_postprocess_title = input_mi.title
diff --git a/ebook_converter/ebooks/conversion/plugins/txt_output.py b/ebook_converter/ebooks/conversion/plugins/txt_output.py
index 2dd9627..07ea689 100644
--- a/ebook_converter/ebooks/conversion/plugins/txt_output.py
+++ b/ebook_converter/ebooks/conversion/plugins/txt_output.py
@@ -9,9 +9,9 @@ import os
import shutil
-from calibre.customize.conversion import OutputFormatPlugin, \
+from ebook_converter.customize.conversion import OutputFormatPlugin, \
OptionRecommendation
-from calibre.ptempfile import TemporaryDirectory, TemporaryFile
+from ebook_converter.ptempfile import TemporaryDirectory, TemporaryFile
NEWLINE_TYPES = ['system', 'unix', 'old_mac', 'windows']
@@ -84,15 +84,15 @@ class TXTOutput(OutputFormatPlugin):
}
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.txt.txtml import TXTMLizer
- from calibre.utils.cleantext import clean_ascii_chars
- from calibre.ebooks.txt.newlines import specified_newlines, TxtNewlines
+ from ebook_converter.ebooks.txt.txtml import TXTMLizer
+ from ebook_converter.utils.cleantext import clean_ascii_chars
+ from ebook_converter.ebooks.txt.newlines import specified_newlines, TxtNewlines
if opts.txt_output_formatting.lower() == 'markdown':
- from calibre.ebooks.txt.markdownml import MarkdownMLizer
+ from ebook_converter.ebooks.txt.markdownml import MarkdownMLizer
self.writer = MarkdownMLizer(log)
elif opts.txt_output_formatting.lower() == 'textile':
- from calibre.ebooks.txt.textileml import TextileMLizer
+ from ebook_converter.ebooks.txt.textileml import TextileMLizer
self.writer = TextileMLizer(log)
else:
self.writer = TXTMLizer(log)
@@ -127,8 +127,8 @@ class TXTZOutput(TXTOutput):
file_type = 'txtz'
def convert(self, oeb_book, output_path, input_plugin, opts, log):
- from calibre.ebooks.oeb.base import OEB_IMAGES
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.oeb.base import OEB_IMAGES
+ from ebook_converter.utils.zipfile import ZipFile
from lxml import etree
with TemporaryDirectory('_txtz_output') as tdir:
diff --git a/ebook_converter/ebooks/conversion/plumber.py b/ebook_converter/ebooks/conversion/plumber.py
index a972050..a11d2cb 100644
--- a/ebook_converter/ebooks/conversion/plumber.py
+++ b/ebook_converter/ebooks/conversion/plumber.py
@@ -8,19 +8,19 @@ __docformat__ = 'restructuredtext en'
import os, re, sys, shutil, pprint, json
from functools import partial
-from calibre.customize.conversion import OptionRecommendation, DummyReporter
-from calibre.customize.ui import input_profiles, output_profiles, \
+from ebook_converter.customize.conversion import OptionRecommendation, DummyReporter
+from ebook_converter.customize.ui import input_profiles, output_profiles, \
plugin_for_input_format, plugin_for_output_format, \
available_input_formats, available_output_formats, \
run_plugins_on_preprocess, run_plugins_on_postprocess
-from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
-from calibre.ptempfile import PersistentTemporaryDirectory
-from calibre.utils.date import parse_date
-from calibre.utils.zipfile import ZipFile
-from calibre import (extract, walk, isbytestring, filesystem_encoding,
+from ebook_converter.ebooks.conversion.preprocess import HTMLPreProcessor
+from ebook_converter.ptempfile import PersistentTemporaryDirectory
+from ebook_converter.utils.date import parse_date
+from ebook_converter.utils.zipfile import ZipFile
+from ebook_converter import (extract, walk, isbytestring, filesystem_encoding,
get_types_map)
-from calibre.constants import __version__
-from polyglot.builtins import unicode_type, string_or_bytes, map
+from ebook_converter.constants import __version__
+from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, map
DEBUG_README=b'''
This debug directory contains snapshots of the e-book as it passes through the
@@ -799,7 +799,7 @@ OptionRecommendation(name='search_replace',
files = list(walk(tdir))
files = [f if isinstance(f, unicode_type) else f.decode(filesystem_encoding)
for f in files]
- from calibre.customize.ui import available_input_formats
+ from ebook_converter.customize.ui import available_input_formats
fmts = set(available_input_formats())
fmts -= {'htm', 'html', 'xhtm', 'xhtml'}
fmts -= set(ARCHIVE_FMTS)
@@ -899,7 +899,7 @@ OptionRecommendation(name='search_replace',
self.changed_options.add(rec)
def opts_to_mi(self, mi):
- from calibre.ebooks.metadata import string_to_authors
+ from ebook_converter.ebooks.metadata import string_to_authors
for x in self.metadata_option_names:
val = getattr(self.opts, x, None)
if val is not None:
@@ -923,10 +923,10 @@ OptionRecommendation(name='search_replace',
setattr(mi, x, val)
def download_cover(self, url):
- from calibre import browser
+ from ebook_converter import browser
from PIL import Image
import io
- from calibre.ptempfile import PersistentTemporaryFile
+ from ebook_converter.ptempfile import PersistentTemporaryFile
self.log('Downloading cover from %r'%url)
br = browser()
raw = br.open_novisit(url).read()
@@ -942,8 +942,8 @@ OptionRecommendation(name='search_replace',
Read all metadata specified by the user. Command line options override
metadata from a specified OPF file.
'''
- from calibre.ebooks.metadata import MetaInformation
- from calibre.ebooks.metadata.opf2 import OPF
+ from ebook_converter.ebooks.metadata import MetaInformation
+ from ebook_converter.ebooks.metadata.opf2 import OPF
mi = MetaInformation(None, [])
if self.opts.read_metadata_from_opf is not None:
self.opts.read_metadata_from_opf = os.path.abspath(
@@ -1003,7 +1003,7 @@ OptionRecommendation(name='search_replace',
if self.opts.verbose > 1:
self.log.debug('Resolved conversion options')
try:
- self.log.debug('calibre version:', __version__)
+ self.log.debug('ebook_converter version:', __version__)
odict = dict(self.opts.__dict__)
for x in ('username', 'password'):
odict.pop(x, None)
@@ -1019,7 +1019,7 @@ OptionRecommendation(name='search_replace',
pass
def dump_oeb(self, oeb, out_dir):
- from calibre.ebooks.oeb.writer import OEBWriter
+ from ebook_converter.ebooks.oeb.writer import OEBWriter
w = OEBWriter(pretty_print=self.opts.pretty_print)
w(oeb, out_dir)
@@ -1054,7 +1054,7 @@ OptionRecommendation(name='search_replace',
self.flush()
if self.opts.embed_all_fonts or self.opts.embed_font_family:
# Start the threaded font scanner now, for performance
- from calibre.utils.fonts.scanner import font_scanner # noqa
+ from ebook_converter.utils.fonts.scanner import font_scanner # noqa
import css_parser, logging
css_parser.log.setLevel(logging.WARN)
get_types_map() # Ensure the mimetypes module is intialized
@@ -1072,7 +1072,7 @@ OptionRecommendation(name='search_replace',
shutil.rmtree(x)
# Run any preprocess plugins
- from calibre.customize.ui import run_plugins_on_preprocess
+ from ebook_converter.customize.ui import run_plugins_on_preprocess
self.input = run_plugins_on_preprocess(self.input)
self.flush()
@@ -1091,7 +1091,7 @@ OptionRecommendation(name='search_replace',
if self.input_fmt == 'azw4' and self.output_plugin.file_type == 'pdf':
self.ui_reporter(0.01, 'AZW4 files are simply wrappers around PDF files.'
' Skipping the conversion and unwrapping the embedded PDF instead')
- from calibre.ebooks.azw4.reader import unwrap
+ from ebook_converter.ebooks.azw4.reader import unwrap
unwrap(stream, self.output)
self.ui_reporter(1.)
self.log(self.output_fmt.upper(), 'output written to', self.output)
@@ -1136,9 +1136,9 @@ OptionRecommendation(name='search_replace',
self.oeb.plumber_output_format = self.output_fmt or ''
- from calibre.ebooks.oeb.transforms.data_url import DataURL
+ from ebook_converter.ebooks.oeb.transforms.data_url import DataURL
DataURL()(self.oeb, self.opts)
- from calibre.ebooks.oeb.transforms.guide import Clean
+ from ebook_converter.ebooks.oeb.transforms.guide import Clean
Clean()(self.oeb, self.opts)
pr(0.1)
self.flush()
@@ -1146,15 +1146,15 @@ OptionRecommendation(name='search_replace',
self.opts.source = self.opts.input_profile
self.opts.dest = self.opts.output_profile
- from calibre.ebooks.oeb.transforms.jacket import RemoveFirstImage
+ from ebook_converter.ebooks.oeb.transforms.jacket import RemoveFirstImage
RemoveFirstImage()(self.oeb, self.opts, self.user_metadata)
- from calibre.ebooks.oeb.transforms.metadata import MergeMetadata
+ from ebook_converter.ebooks.oeb.transforms.metadata import MergeMetadata
MergeMetadata()(self.oeb, self.user_metadata, self.opts,
override_input_metadata=self.override_input_metadata)
pr(0.2)
self.flush()
- from calibre.ebooks.oeb.transforms.structure import DetectStructure
+ from ebook_converter.ebooks.oeb.transforms.structure import DetectStructure
DetectStructure()(self.oeb, self.opts)
pr(0.35)
self.flush()
@@ -1166,7 +1166,7 @@ OptionRecommendation(name='search_replace',
if item is not None and item.count() == 0:
self.oeb.toc.remove(item)
- from calibre.ebooks.oeb.transforms.flatcss import CSSFlattener
+ from ebook_converter.ebooks.oeb.transforms.flatcss import CSSFlattener
fbase = self.opts.base_font_size
if fbase < 1e-4:
fbase = float(self.opts.dest.fbase)
@@ -1180,7 +1180,7 @@ OptionRecommendation(name='search_replace',
self.log.error('Invalid font size key: %r ignoring'%fkey)
fkey = self.opts.dest.fkey
- from calibre.ebooks.oeb.transforms.jacket import Jacket
+ from ebook_converter.ebooks.oeb.transforms.jacket import Jacket
Jacket()(self.oeb, self.opts, self.user_metadata)
pr(0.4)
self.flush()
@@ -1205,11 +1205,11 @@ OptionRecommendation(name='search_replace',
if self.opts.linearize_tables and \
self.output_plugin.file_type not in ('mobi', 'lrf'):
- from calibre.ebooks.oeb.transforms.linearize_tables import LinearizeTables
+ from ebook_converter.ebooks.oeb.transforms.linearize_tables import LinearizeTables
LinearizeTables()(self.oeb, self.opts)
if self.opts.unsmarten_punctuation:
- from calibre.ebooks.oeb.transforms.unsmarten import UnsmartenPunctuation
+ from ebook_converter.ebooks.oeb.transforms.unsmarten import UnsmartenPunctuation
UnsmartenPunctuation()(self.oeb, self.opts)
mobi_file_type = getattr(self.opts, 'mobi_file_type', 'old')
@@ -1235,23 +1235,23 @@ OptionRecommendation(name='search_replace',
self.opts.insert_blank_line = oibl
self.opts.remove_paragraph_spacing = orps
- from calibre.ebooks.oeb.transforms.page_margin import \
+ from ebook_converter.ebooks.oeb.transforms.page_margin import \
RemoveFakeMargins, RemoveAdobeMargins
RemoveFakeMargins()(self.oeb, self.log, self.opts)
RemoveAdobeMargins()(self.oeb, self.log, self.opts)
if self.opts.embed_all_fonts:
- from calibre.ebooks.oeb.transforms.embed_fonts import EmbedFonts
+ from ebook_converter.ebooks.oeb.transforms.embed_fonts import EmbedFonts
EmbedFonts()(self.oeb, self.log, self.opts)
if self.opts.subset_embedded_fonts and self.output_plugin.file_type != 'pdf':
- from calibre.ebooks.oeb.transforms.subset import SubsetFonts
+ from ebook_converter.ebooks.oeb.transforms.subset import SubsetFonts
SubsetFonts()(self.oeb, self.log, self.opts)
pr(0.9)
self.flush()
- from calibre.ebooks.oeb.transforms.trimmanifest import ManifestTrimmer
+ from ebook_converter.ebooks.oeb.transforms.trimmanifest import ManifestTrimmer
self.log.info('Cleaning up manifest...')
trimmer = ManifestTrimmer()
@@ -1296,7 +1296,7 @@ def create_oebbook(log, path_or_stream, opts, reader=None,
'''
Create an OEBBook.
'''
- from calibre.ebooks.oeb.base import OEBBook
+ from ebook_converter.ebooks.oeb.base import OEBBook
html_preprocessor = HTMLPreProcessor(log, opts, regex_wizard_callback=regex_wizard_callback)
if not encoding:
encoding = None
@@ -1310,7 +1310,7 @@ def create_oebbook(log, path_or_stream, opts, reader=None,
log('Parsing all content...')
oeb.removed_items_to_ignore = removed_items
if reader is None:
- from calibre.ebooks.oeb.reader import OEBReader
+ from ebook_converter.ebooks.oeb.reader import OEBReader
reader = OEBReader
reader()(oeb, path_or_stream)
@@ -1318,7 +1318,7 @@ def create_oebbook(log, path_or_stream, opts, reader=None,
def create_dummy_plumber(input_format, output_format):
- from calibre.utils.logging import Log
+ from ebook_converter.utils.logging import Log
input_format = input_format.lower()
output_format = output_format.lower()
output_path = 'dummy.'+output_format
diff --git a/ebook_converter/ebooks/conversion/preprocess.py b/ebook_converter/ebooks/conversion/preprocess.py
index c597e00..cc821c7 100644
--- a/ebook_converter/ebooks/conversion/preprocess.py
+++ b/ebook_converter/ebooks/conversion/preprocess.py
@@ -9,8 +9,8 @@ __docformat__ = 'restructuredtext en'
import functools, re, json
from math import ceil
-from calibre import entity_to_unicode, as_unicode
-from polyglot.builtins import unicode_type, range
+from ebook_converter import entity_to_unicode, as_unicode
+from ebook_converter.polyglot.builtins import unicode_type, range
XMLDECL_RE = re.compile(r'^\s*<[?]xml.*?[?]>')
SVG_NS = 'http://www.w3.org/2000/svg'
@@ -70,9 +70,9 @@ def wrap_lines(match):
def smarten_punctuation(html, log=None):
- from calibre.utils.smartypants import smartyPants
- from calibre.ebooks.chardet import substitute_entites
- from calibre.ebooks.conversion.utils import HeuristicProcessor
+ from ebook_converter.utils.smartypants import smartyPants
+ from ebook_converter.ebooks.chardet import substitute_entites
+ from ebook_converter.ebooks.conversion.utils import HeuristicProcessor
preprocessor = HeuristicProcessor(log=log)
from uuid import uuid4
start = 'calibre-smartypants-'+unicode_type(uuid4())
@@ -321,7 +321,7 @@ class CSSPreProcessor(object):
return start + end
def __call__(self, data, add_namespace=False):
- from calibre.ebooks.oeb.base import XHTML_CSS_NAMESPACE
+ from ebook_converter.ebooks.oeb.base import XHTML_CSS_NAMESPACE
data = self.MS_PAT.sub(self.ms_sub, data)
if not add_namespace:
return data
@@ -497,7 +497,7 @@ class HTMLPreProcessor(object):
# Function for processing search and replace
def do_search_replace(search_pattern, replace_txt):
- from calibre.ebooks.conversion.search_replace import compile_regular_expression
+ from ebook_converter.ebooks.conversion.search_replace import compile_regular_expression
try:
search_re = compile_regular_expression(search_pattern)
if not replace_txt:
@@ -595,7 +595,7 @@ class HTMLPreProcessor(object):
html = dehyphenator(html,'html', length)
if is_pdftohtml:
- from calibre.ebooks.conversion.utils import HeuristicProcessor
+ from ebook_converter.ebooks.conversion.utils import HeuristicProcessor
pdf_markup = HeuristicProcessor(self.extra_opts, None)
totalwords = 0
if pdf_markup.get_word_count(html) > 7000:
@@ -614,15 +614,15 @@ class HTMLPreProcessor(object):
html = XMLDECL_RE.sub('', html)
if getattr(self.extra_opts, 'asciiize', False):
- from calibre.utils.localization import get_udc
- from calibre.utils.mreplace import MReplace
+ from ebook_converter.utils.localization import get_udc
+ from ebook_converter.utils.mreplace import MReplace
unihandecoder = get_udc()
mr = MReplace(data={'«':'<'*3, '»':'>'*3})
html = mr.mreplace(html)
html = unihandecoder.decode(html)
if getattr(self.extra_opts, 'enable_heuristics', False):
- from calibre.ebooks.conversion.utils import HeuristicProcessor
+ from ebook_converter.ebooks.conversion.utils import HeuristicProcessor
preprocessor = HeuristicProcessor(self.extra_opts, self.log)
html = preprocessor(html)
@@ -637,7 +637,7 @@ class HTMLPreProcessor(object):
except AttributeError:
unsupported_unicode_chars = ''
if unsupported_unicode_chars:
- from calibre.utils.localization import get_udc
+ from ebook_converter.utils.localization import get_udc
unihandecoder = get_udc()
for char in unsupported_unicode_chars:
asciichar = unihandecoder.decode(char)
diff --git a/ebook_converter/ebooks/conversion/utils.py b/ebook_converter/ebooks/conversion/utils.py
index 991c560..a53dad5 100644
--- a/ebook_converter/ebooks/conversion/utils.py
+++ b/ebook_converter/ebooks/conversion/utils.py
@@ -8,10 +8,10 @@ __docformat__ = 'restructuredtext en'
import re
from math import ceil
-from calibre.ebooks.conversion.preprocess import DocAnalysis, Dehyphenator
-from calibre.utils.logging import default_log
-from calibre.utils.wordcount import get_wordcount_obj
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.conversion.preprocess import DocAnalysis, Dehyphenator
+from ebook_converter.utils.logging import default_log
+from ebook_converter.utils.wordcount import get_wordcount_obj
+from ebook_converter.polyglot.builtins import unicode_type
class HeuristicProcessor(object):
@@ -49,7 +49,7 @@ class HeuristicProcessor(object):
return ')(?P.*?)', re.IGNORECASE|re.DOTALL)
html = outerhtml.sub(self.txt_process, html)
- from calibre.ebooks.conversion.preprocess import convert_entities
+ from ebook_converter.ebooks.conversion.preprocess import convert_entities
html = re.sub(r'&(\S+?);', convert_entities, html)
else:
# Add markup naively
@@ -616,7 +616,7 @@ class HeuristicProcessor(object):
elif re.match('^
'
else:
- from calibre.utils.html2text import html2text
+ from ebook_converter.utils.html2text import html2text
replacement_break = html2text(replacement_break)
replacement_break = re.sub('\\s', ' ', replacement_break)
scene_break = self.scene_break_open+replacement_break+'
'
diff --git a/ebook_converter/ebooks/docx/block_styles.py b/ebook_converter/ebooks/docx/block_styles.py
index fdd61ad..00473e8 100644
--- a/ebook_converter/ebooks/docx/block_styles.py
+++ b/ebook_converter/ebooks/docx/block_styles.py
@@ -7,7 +7,7 @@ __copyright__ = '2013, Kovid Goyal '
import numbers
from collections import OrderedDict
-from polyglot.builtins import iteritems
+from ebook_converter.polyglot.builtins import iteritems
class Inherit(object):
diff --git a/ebook_converter/ebooks/docx/char_styles.py b/ebook_converter/ebooks/docx/char_styles.py
index c443dad..1727f34 100644
--- a/ebook_converter/ebooks/docx/char_styles.py
+++ b/ebook_converter/ebooks/docx/char_styles.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
from collections import OrderedDict
-from calibre.ebooks.docx.block_styles import ( # noqa
+from ebook_converter.ebooks.docx.block_styles import ( # noqa
inherit, simple_color, LINE_STYLES, simple_float, binary_property, read_shd)
# Read from XML {{{
@@ -89,7 +89,7 @@ def read_lang(parent, dest, XPath, get):
except (ValueError, TypeError):
ans = val
else:
- from calibre.ebooks.docx.lcid import lcid
+ from ebook_converter.ebooks.docx.lcid import lcid
val = lcid.get(code, None)
if val:
ans = val
diff --git a/ebook_converter/ebooks/docx/cleanup.py b/ebook_converter/ebooks/docx/cleanup.py
index 8f79458..671683d 100644
--- a/ebook_converter/ebooks/docx/cleanup.py
+++ b/ebook_converter/ebooks/docx/cleanup.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
import os
-from polyglot.builtins import itervalues, range
+from ebook_converter.polyglot.builtins import itervalues, range
NBSP = '\xa0'
@@ -218,7 +218,7 @@ def cleanup_markup(log, root, styles, dest_dir, detect_cover, XPath):
img = img[0]
path = os.path.join(dest_dir, img.get('src'))
if os.path.exists(path) and before_count(root, img, limit=10) < 5:
- from calibre.utils.imghdr import identify
+ from ebook_converter.utils.imghdr import identify
try:
with lopen(path, 'rb') as imf:
fmt, width, height = identify(imf)
diff --git a/ebook_converter/ebooks/docx/container.py b/ebook_converter/ebooks/docx/container.py
index 7bd6768..bfa707a 100644
--- a/ebook_converter/ebooks/docx/container.py
+++ b/ebook_converter/ebooks/docx/container.py
@@ -9,16 +9,16 @@ import os, sys, shutil
from lxml import etree
-from calibre import walk, guess_type
-from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string
-from calibre.ebooks.metadata.book.base import Metadata
-from calibre.ebooks.docx import InvalidDOCX
-from calibre.ebooks.docx.names import DOCXNamespace
-from calibre.ptempfile import PersistentTemporaryDirectory
-from calibre.utils.localization import canonicalize_lang
-from calibre.utils.logging import default_log
-from calibre.utils.zipfile import ZipFile
-from calibre.utils.xml_parse import safe_xml_fromstring
+from ebook_converter import walk, guess_type
+from ebook_converter.ebooks.metadata import string_to_authors, authors_to_sort_string
+from ebook_converter.ebooks.metadata.book.base import Metadata
+from ebook_converter.ebooks.docx import InvalidDOCX
+from ebook_converter.ebooks.docx.names import DOCXNamespace
+from ebook_converter.ptempfile import PersistentTemporaryDirectory
+from ebook_converter.utils.localization import canonicalize_lang
+from ebook_converter.utils.logging import default_log
+from ebook_converter.utils.zipfile import ZipFile
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
def fromstring(raw, parser=None):
@@ -113,7 +113,7 @@ class DOCX(object):
except:
self.log.exception('DOCX appears to be invalid ZIP file, trying a'
' more forgiving ZIP parser')
- from calibre.utils.localunzip import extractall
+ from ebook_converter.utils.localunzip import extractall
stream.seek(0)
extractall(stream, self.tdir)
diff --git a/ebook_converter/ebooks/docx/fields.py b/ebook_converter/ebooks/docx/fields.py
index 7400bcd..3e2bd33 100644
--- a/ebook_converter/ebooks/docx/fields.py
+++ b/ebook_converter/ebooks/docx/fields.py
@@ -7,8 +7,8 @@ __copyright__ = '2013, Kovid Goyal '
import re
-from calibre.ebooks.docx.index import process_index, polish_index_markup
-from polyglot.builtins import iteritems, native_string_type
+from ebook_converter.ebooks.docx.index import process_index, polish_index_markup
+from ebook_converter.polyglot.builtins import iteritems, native_string_type
class Field(object):
diff --git a/ebook_converter/ebooks/docx/fonts.py b/ebook_converter/ebooks/docx/fonts.py
index ad5c7b7..1352a64 100644
--- a/ebook_converter/ebooks/docx/fonts.py
+++ b/ebook_converter/ebooks/docx/fonts.py
@@ -8,12 +8,12 @@ __copyright__ = '2013, Kovid Goyal '
import os, re
from collections import namedtuple
-from calibre.ebooks.docx.block_styles import binary_property, inherit
-from calibre.utils.filenames import ascii_filename
-from calibre.utils.fonts.scanner import font_scanner, NoFonts
-from calibre.utils.fonts.utils import panose_to_css_generic_family, is_truetype_font
-from calibre.utils.icu import ord_string
-from polyglot.builtins import codepoint_to_chr, iteritems, range
+from ebook_converter.ebooks.docx.block_styles import binary_property, inherit
+from ebook_converter.utils.filenames import ascii_filename
+from ebook_converter.utils.fonts.scanner import font_scanner, NoFonts
+from ebook_converter.utils.fonts.utils import panose_to_css_generic_family, is_truetype_font
+from ebook_converter.utils.icu import ord_string
+from ebook_converter.polyglot.builtins import codepoint_to_chr, iteritems, range
Embed = namedtuple('Embed', 'name key subsetted')
diff --git a/ebook_converter/ebooks/docx/footnotes.py b/ebook_converter/ebooks/docx/footnotes.py
index a97d2a7..286eefd 100644
--- a/ebook_converter/ebooks/docx/footnotes.py
+++ b/ebook_converter/ebooks/docx/footnotes.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
from collections import OrderedDict
-from polyglot.builtins import iteritems, unicode_type
+from ebook_converter.polyglot.builtins import iteritems, unicode_type
class Note(object):
diff --git a/ebook_converter/ebooks/docx/images.py b/ebook_converter/ebooks/docx/images.py
index 764aa17..4cf346d 100644
--- a/ebook_converter/ebooks/docx/images.py
+++ b/ebook_converter/ebooks/docx/images.py
@@ -9,12 +9,12 @@ import os
from lxml.html.builder import IMG, HR
-from calibre.constants import iswindows
-from calibre.ebooks.docx.names import barename
-from calibre.utils.filenames import ascii_filename
-from calibre.utils.img import resize_to_fit, image_to_data
-from calibre.utils.imghdr import what
-from polyglot.builtins import iteritems, itervalues
+from ebook_converter.constants import iswindows
+from ebook_converter.ebooks.docx.names import barename
+from ebook_converter.utils.filenames import ascii_filename
+from ebook_converter.utils.img import resize_to_fit, image_to_data
+from ebook_converter.utils.imghdr import what
+from ebook_converter.polyglot.builtins import iteritems, itervalues
class LinkedImageNotFound(ValueError):
@@ -143,7 +143,7 @@ class Images(object):
if ext == 'emf':
# For an example, see: https://bugs.launchpad.net/bugs/1224849
self.log('Found an EMF image: %s, trying to extract embedded raster image' % fname)
- from calibre.utils.wmf.emf import emf_unwrap
+ from ebook_converter.utils.wmf.emf import emf_unwrap
try:
raw = emf_unwrap(raw)
except Exception:
diff --git a/ebook_converter/ebooks/docx/index.py b/ebook_converter/ebooks/docx/index.py
index 974d25d..a28723e 100644
--- a/ebook_converter/ebooks/docx/index.py
+++ b/ebook_converter/ebooks/docx/index.py
@@ -9,8 +9,8 @@ from operator import itemgetter
from lxml import etree
-from calibre.utils.icu import partition_by_first_letter, sort_key
-from polyglot.builtins import iteritems, filter
+from ebook_converter.utils.icu import partition_by_first_letter, sort_key
+from ebook_converter.polyglot.builtins import iteritems, filter
def get_applicable_xe_fields(index, xe_fields, XPath, expand):
diff --git a/ebook_converter/ebooks/docx/names.py b/ebook_converter/ebooks/docx/names.py
index dac2d0e..a0e2f1c 100644
--- a/ebook_converter/ebooks/docx/names.py
+++ b/ebook_converter/ebooks/docx/names.py
@@ -9,8 +9,8 @@ import re
from lxml.etree import XPath as X
-from calibre.utils.filenames import ascii_text
-from polyglot.builtins import iteritems
+from ebook_converter.utils.filenames import ascii_text
+from ebook_converter.polyglot.builtins import iteritems
# Names {{{
TRANSITIONAL_NAMES = {
diff --git a/ebook_converter/ebooks/docx/numbering.py b/ebook_converter/ebooks/docx/numbering.py
index da33d6a..60dff17 100644
--- a/ebook_converter/ebooks/docx/numbering.py
+++ b/ebook_converter/ebooks/docx/numbering.py
@@ -11,10 +11,10 @@ from functools import partial
from lxml.html.builder import OL, UL, SPAN
-from calibre.ebooks.docx.block_styles import ParagraphStyle
-from calibre.ebooks.docx.char_styles import RunStyle, inherit
-from calibre.ebooks.metadata import roman
-from polyglot.builtins import iteritems, unicode_type
+from ebook_converter.ebooks.docx.block_styles import ParagraphStyle
+from ebook_converter.ebooks.docx.char_styles import RunStyle, inherit
+from ebook_converter.ebooks.metadata import roman
+from ebook_converter.polyglot.builtins import iteritems, unicode_type
STYLE_MAP = {
'aiueo': 'hiragana',
diff --git a/ebook_converter/ebooks/docx/styles.py b/ebook_converter/ebooks/docx/styles.py
index bf2eb93..ce869fb 100644
--- a/ebook_converter/ebooks/docx/styles.py
+++ b/ebook_converter/ebooks/docx/styles.py
@@ -8,10 +8,10 @@ __copyright__ = '2013, Kovid Goyal '
import textwrap
from collections import OrderedDict, Counter
-from calibre.ebooks.docx.block_styles import ParagraphStyle, inherit, twips
-from calibre.ebooks.docx.char_styles import RunStyle
-from calibre.ebooks.docx.tables import TableStyle
-from polyglot.builtins import iteritems, itervalues
+from ebook_converter.ebooks.docx.block_styles import ParagraphStyle, inherit, twips
+from ebook_converter.ebooks.docx.char_styles import RunStyle
+from ebook_converter.ebooks.docx.tables import TableStyle
+from ebook_converter.polyglot.builtins import iteritems, itervalues
class PageProperties(object):
diff --git a/ebook_converter/ebooks/docx/tables.py b/ebook_converter/ebooks/docx/tables.py
index 6f537e6..3360aab 100644
--- a/ebook_converter/ebooks/docx/tables.py
+++ b/ebook_converter/ebooks/docx/tables.py
@@ -7,9 +7,9 @@ __copyright__ = '2013, Kovid Goyal '
from lxml.html.builder import TABLE, TR, TD
-from calibre.ebooks.docx.block_styles import inherit, read_shd as rs, read_border, binary_property, border_props, ParagraphStyle, border_to_css
-from calibre.ebooks.docx.char_styles import RunStyle
-from polyglot.builtins import filter, iteritems, itervalues, range, unicode_type
+from ebook_converter.ebooks.docx.block_styles import inherit, read_shd as rs, read_border, binary_property, border_props, ParagraphStyle, border_to_css
+from ebook_converter.ebooks.docx.char_styles import RunStyle
+from ebook_converter.polyglot.builtins import filter, iteritems, itervalues, range, unicode_type
# Read from XML {{{
read_shd = rs
diff --git a/ebook_converter/ebooks/docx/to_html.py b/ebook_converter/ebooks/docx/to_html.py
index 081095f..d4a80b3 100644
--- a/ebook_converter/ebooks/docx/to_html.py
+++ b/ebook_converter/ebooks/docx/to_html.py
@@ -12,23 +12,23 @@ from lxml import html
from lxml.html.builder import (
HTML, HEAD, TITLE, BODY, LINK, META, P, SPAN, BR, DIV, A, DT, DL, DD, H1)
-from calibre import guess_type
-from calibre.ebooks.docx.container import DOCX, fromstring
-from calibre.ebooks.docx.names import XML, generate_anchor
-from calibre.ebooks.docx.styles import Styles, inherit, PageProperties
-from calibre.ebooks.docx.numbering import Numbering
-from calibre.ebooks.docx.fonts import Fonts, is_symbol_font, map_symbol_text
-from calibre.ebooks.docx.images import Images
-from calibre.ebooks.docx.tables import Tables
-from calibre.ebooks.docx.footnotes import Footnotes
-from calibre.ebooks.docx.cleanup import cleanup_markup
-from calibre.ebooks.docx.theme import Theme
-from calibre.ebooks.docx.toc import create_toc
-from calibre.ebooks.docx.fields import Fields
-from calibre.ebooks.docx.settings import Settings
-from calibre.ebooks.metadata.opf2 import OPFCreator
-from calibre.utils.localization import canonicalize_lang, lang_as_iso639_1
-from polyglot.builtins import iteritems, itervalues, filter, getcwd, map, unicode_type
+from ebook_converter import guess_type
+from ebook_converter.ebooks.docx.container import DOCX, fromstring
+from ebook_converter.ebooks.docx.names import XML, generate_anchor
+from ebook_converter.ebooks.docx.styles import Styles, inherit, PageProperties
+from ebook_converter.ebooks.docx.numbering import Numbering
+from ebook_converter.ebooks.docx.fonts import Fonts, is_symbol_font, map_symbol_text
+from ebook_converter.ebooks.docx.images import Images
+from ebook_converter.ebooks.docx.tables import Tables
+from ebook_converter.ebooks.docx.footnotes import Footnotes
+from ebook_converter.ebooks.docx.cleanup import cleanup_markup
+from ebook_converter.ebooks.docx.theme import Theme
+from ebook_converter.ebooks.docx.toc import create_toc
+from ebook_converter.ebooks.docx.fields import Fields
+from ebook_converter.ebooks.docx.settings import Settings
+from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+from ebook_converter.utils.localization import canonicalize_lang, lang_as_iso639_1
+from ebook_converter.polyglot.builtins import iteritems, itervalues, filter, getcwd, map, unicode_type
NBSP = '\xa0'
@@ -830,7 +830,7 @@ class Convert(object):
if __name__ == '__main__':
import shutil
- from calibre.utils.logging import default_log
+ from ebook_converter.utils.logging import default_log
default_log.filter_level = default_log.DEBUG
dest_dir = os.path.join(getcwd(), 'docx_input')
if os.path.exists(dest_dir):
diff --git a/ebook_converter/ebooks/docx/toc.py b/ebook_converter/ebooks/docx/toc.py
index 3c60701..41bf7ce 100644
--- a/ebook_converter/ebooks/docx/toc.py
+++ b/ebook_converter/ebooks/docx/toc.py
@@ -10,9 +10,9 @@ from itertools import count
from lxml.etree import tostring
-from calibre.ebooks.metadata.toc import TOC
-from calibre.ebooks.oeb.polish.toc import elem_to_toc_text
-from polyglot.builtins import iteritems, range
+from ebook_converter.ebooks.metadata.toc import TOC
+from ebook_converter.ebooks.oeb.polish.toc import elem_to_toc_text
+from ebook_converter.polyglot.builtins import iteritems, range
def from_headings(body, log, namespace, num_levels=3):
diff --git a/ebook_converter/ebooks/html/__init__.py b/ebook_converter/ebooks/html/__init__.py
index 720ff71..e69de29 100644
--- a/ebook_converter/ebooks/html/__init__.py
+++ b/ebook_converter/ebooks/html/__init__.py
@@ -1,7 +0,0 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2009, Kovid Goyal '
-__docformat__ = 'restructuredtext en'
diff --git a/ebook_converter/ebooks/html/input.py b/ebook_converter/ebooks/html/input.py
index c87af5d..5da56db 100644
--- a/ebook_converter/ebooks/html/input.py
+++ b/ebook_converter/ebooks/html/input.py
@@ -13,12 +13,12 @@ Input plugin for HTML or OPF ebooks.
import os, re, sys, errno as gerrno
-from calibre.ebooks.oeb.base import urlunquote
-from calibre.ebooks.chardet import detect_xml_encoding
-from calibre.constants import iswindows
-from calibre import unicode_path, as_unicode, replace_entities
-from polyglot.builtins import is_py3, unicode_type
-from polyglot.urllib import urlparse, urlunparse
+from ebook_converter.ebooks.oeb.base import urlunquote
+from ebook_converter.ebooks.chardet import detect_xml_encoding
+from ebook_converter.constants import iswindows
+from ebook_converter import unicode_path, as_unicode, replace_entities
+from ebook_converter.polyglot.builtins import is_py3, unicode_type
+from ebook_converter.polyglot.urllib import urlparse, urlunparse
class Link(object):
diff --git a/ebook_converter/ebooks/html/to_zip.py b/ebook_converter/ebooks/html/to_zip.py
index 4ac28c3..0833893 100644
--- a/ebook_converter/ebooks/html/to_zip.py
+++ b/ebook_converter/ebooks/html/to_zip.py
@@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
import textwrap, os, glob
-from calibre.customize import FileTypePlugin
-from calibre.constants import numeric_version
-from polyglot.builtins import unicode_type
+from ebook_converter.customize import FileTypePlugin
+from ebook_converter.constants import numeric_version
+from ebook_converter.polyglot.builtins import unicode_type
class HTML2ZIP(FileTypePlugin):
@@ -28,11 +28,11 @@ every time you add an HTML file to the library.\
def run(self, htmlfile):
import codecs
- from calibre import prints
- from calibre.ptempfile import TemporaryDirectory
- from calibre.gui2.convert.gui_conversion import gui_convert
- from calibre.customize.conversion import OptionRecommendation
- from calibre.ebooks.epub import initialize_container
+ from ebook_converter import prints
+ from ebook_converter.ptempfile import TemporaryDirectory
+ from ebook_converter.gui2.convert.gui_conversion import gui_convert
+ from ebook_converter.customize.conversion import OptionRecommendation
+ from ebook_converter.ebooks.epub import initialize_container
with TemporaryDirectory('_plugin_html2zip') as tdir:
recs =[('debug_pipeline', tdir, OptionRecommendation.HIGH)]
@@ -86,7 +86,7 @@ every time you add an HTML file to the library.\
button_box.accepted.connect(config_dialog.accept)
button_box.rejected.connect(config_dialog.reject)
config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
- from calibre.customize.ui import (plugin_customization,
+ from ebook_converter.customize.ui import (plugin_customization,
customize_plugin)
help_text = self.customization_help(gui=True)
help_text = QLabel(help_text, config_dialog)
diff --git a/ebook_converter/ebooks/lrf/__init__.py b/ebook_converter/ebooks/lrf/__init__.py
index 6be9e69..35ddeee 100644
--- a/ebook_converter/ebooks/lrf/__init__.py
+++ b/ebook_converter/ebooks/lrf/__init__.py
@@ -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):
diff --git a/ebook_converter/ebooks/lrf/html/__init__.py b/ebook_converter/ebooks/lrf/html/__init__.py
index cb4d468..e69de29 100644
--- a/ebook_converter/ebooks/lrf/html/__init__.py
+++ b/ebook_converter/ebooks/lrf/html/__init__.py
@@ -1,10 +0,0 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2008, Kovid Goyal '
-"""
-This package contains code to convert HTML ebooks to LRF ebooks.
-"""
-
-__docformat__ = "epytext"
-__author__ = "Kovid Goyal "
diff --git a/ebook_converter/ebooks/lrf/html/convert_from.py b/ebook_converter/ebooks/lrf/html/convert_from.py
index 285acc3..52fbf81 100644
--- a/ebook_converter/ebooks/lrf/html/convert_from.py
+++ b/ebook_converter/ebooks/lrf/html/convert_from.py
@@ -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:
diff --git a/ebook_converter/ebooks/lrf/html/table.py b/ebook_converter/ebooks/lrf/html/table.py
index 3542056..deb3759 100644
--- a/ebook_converter/ebooks/lrf/html/table.py
+++ b/ebook_converter/ebooks/lrf/html/table.py
@@ -4,11 +4,11 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
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)
diff --git a/ebook_converter/ebooks/lrf/pylrs/elements.py b/ebook_converter/ebooks/lrf/pylrs/elements.py
index fa2b8a0..96ccb1e 100644
--- a/ebook_converter/ebooks/lrf/pylrs/elements.py
+++ b/ebook_converter/ebooks/lrf/pylrs/elements.py
@@ -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):
diff --git a/ebook_converter/ebooks/lrf/pylrs/pylrf.py b/ebook_converter/ebooks/lrf/pylrs/pylrf.py
index bca86f2..a8c12d2 100644
--- a/ebook_converter/ebooks/lrf/pylrs/pylrf.py
+++ b/ebook_converter/ebooks/lrf/pylrs/pylrf.py
@@ -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"
diff --git a/ebook_converter/ebooks/lrf/pylrs/pylrs.py b/ebook_converter/ebooks/lrf/pylrs/pylrs.py
index 8816cbc..fa95928 100644
--- a/ebook_converter/ebooks/lrf/pylrs/pylrs.py
+++ b/ebook_converter/ebooks/lrf/pylrs/pylrs.py
@@ -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):
diff --git a/ebook_converter/ebooks/metadata/__init__.py b/ebook_converter/ebooks/metadata/__init__.py
index 158cc91..a218924 100644
--- a/ebook_converter/ebooks/metadata/__init__.py
+++ b/ebook_converter/ebooks/metadata/__init__.py
@@ -11,10 +11,10 @@ Provides abstraction for metadata reading.writing from a variety of ebook format
"""
import os, sys, re
-from calibre import relpath, guess_type, prints, force_unicode
-from calibre.utils.config_base import tweaks
-from polyglot.builtins import codepoint_to_chr, unicode_type, range, map, zip, getcwd, iteritems, itervalues, as_unicode
-from polyglot.urllib import quote, unquote, urlparse
+from ebook_converter import relpath, guess_type, prints, force_unicode
+from ebook_converter.utils.config_base import tweaks
+from ebook_converter.polyglot.builtins import codepoint_to_chr, unicode_type, range, map, zip, getcwd, iteritems, itervalues, as_unicode
+from ebook_converter.polyglot.urllib import quote, unquote, urlparse
try:
@@ -131,7 +131,7 @@ def get_title_sort_pat(lang=None):
if ans is not None:
return ans
q = lang
- from calibre.utils.localization import canonicalize_lang, get_lang
+ from ebook_converter.utils.localization import canonicalize_lang, get_lang
if lang is None:
q = tweaks['default_language_for_title_sort']
if q is None:
@@ -348,7 +348,7 @@ def MetaInformation(title, authors=(_('Unknown'),)):
@param title: title or ``_('Unknown')`` or a MetaInformation object
@param authors: List of strings or []
'''
- from calibre.ebooks.metadata.book.base import Metadata
+ from ebook_converter.ebooks.metadata.book.base import Metadata
mi = None
if hasattr(title, 'title') and hasattr(title, 'authors'):
mi = title
diff --git a/ebook_converter/ebooks/metadata/archive.py b/ebook_converter/ebooks/metadata/archive.py
index 23be91d..bffa84e 100644
--- a/ebook_converter/ebooks/metadata/archive.py
+++ b/ebook_converter/ebooks/metadata/archive.py
@@ -9,9 +9,9 @@ __docformat__ = 'restructuredtext en'
import os
from contextlib import closing
-from calibre.customize import FileTypePlugin
-from calibre.utils.localization import canonicalize_lang
-from polyglot.builtins import filter, unicode_type
+from ebook_converter.customize import FileTypePlugin
+from ebook_converter.utils.localization import canonicalize_lang
+from ebook_converter.polyglot.builtins import filter, unicode_type
def is_comic(list_of_names):
@@ -22,7 +22,7 @@ def is_comic(list_of_names):
def archive_type(stream):
- from calibre.utils.zipfile import stringFileHeader
+ from ebook_converter.utils.zipfile import stringFileHeader
try:
pos = stream.tell()
except:
@@ -51,7 +51,7 @@ class KPFExtract(FileTypePlugin):
on_import = True
def run(self, archive):
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
with ZipFile(archive, 'r') as zf:
fnames = zf.namelist()
candidates = [x for x in fnames if x.lower().endswith('.docx')]
@@ -74,10 +74,10 @@ class ArchiveExtract(FileTypePlugin):
on_import = True
def run(self, archive):
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
is_rar = archive.lower().endswith('.rar')
if is_rar:
- from calibre.utils.unrar import extract_member, names
+ from ebook_converter.utils.unrar import extract_member, names
else:
zf = ZipFile(archive, 'r')
@@ -166,7 +166,7 @@ def get_comic_book_info(d, mi, series_index='volume'):
mi.comments = comments.strip()
pubm, puby = d.get('publicationMonth', None), d.get('publicationYear', None)
if puby is not None:
- from calibre.utils.date import parse_only_date
+ from ebook_converter.utils.date import parse_only_date
from datetime import date
try:
dt = date(puby, 6 if pubm is None else pubm, 15)
@@ -178,7 +178,7 @@ def get_comic_book_info(d, mi, series_index='volume'):
def parse_comic_comment(comment, series_index='volume'):
# See http://code.google.com/p/comicbookinfo/wiki/Example
- from calibre.ebooks.metadata import MetaInformation
+ from ebook_converter.ebooks.metadata import MetaInformation
import json
mi = MetaInformation(None, None)
m = json.loads(comment)
@@ -193,11 +193,11 @@ def parse_comic_comment(comment, series_index='volume'):
def get_comic_metadata(stream, stream_type, series_index='volume'):
comment = None
if stream_type == 'cbz':
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.utils.zipfile import ZipFile
zf = ZipFile(stream)
comment = zf.comment
elif stream_type == 'cbr':
- from calibre.utils.unrar import comment as get_comment
+ from ebook_converter.utils.unrar import comment as get_comment
comment = get_comment(stream)
return parse_comic_comment(comment or b'{}', series_index=series_index)
diff --git a/ebook_converter/ebooks/metadata/book/base.py b/ebook_converter/ebooks/metadata/book/base.py
index 87eba2d..cb5c0bf 100644
--- a/ebook_converter/ebooks/metadata/book/base.py
+++ b/ebook_converter/ebooks/metadata/book/base.py
@@ -8,14 +8,14 @@ __docformat__ = 'restructuredtext en'
import copy, traceback
-from calibre import prints
-from calibre.constants import DEBUG, ispy3
-from calibre.ebooks.metadata.book import (SC_COPYABLE_FIELDS,
+from ebook_converter import prints
+from ebook_converter.constants import DEBUG, ispy3
+from ebook_converter.ebooks.metadata.book import (SC_COPYABLE_FIELDS,
SC_FIELDS_COPY_NOT_NULL, STANDARD_METADATA_FIELDS,
TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS)
-from calibre.library.field_metadata import FieldMetadata
-from calibre.utils.icu import sort_key
-from polyglot.builtins import iteritems, unicode_type, filter, map
+from ebook_converter.library.field_metadata import FieldMetadata
+from ebook_converter.utils.icu import sort_key
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, filter, map
# Special sets used to optimize the performance of getting and setting
# attributes on Metadata objects
@@ -52,7 +52,7 @@ def reset_field_metadata():
field_metadata = FieldMetadata()
-ck = lambda typ: icu_lower(typ).strip().replace(':', '').replace(',', '')
+ck = lambda typ: typ.lower().strip().replace(':', '').replace(',', '')
cv = lambda val: val.strip().replace(',', '|')
@@ -97,7 +97,7 @@ class Metadata(object):
# List of strings or []
self.author = list(authors) if authors else [] # Needed for backward compatibility
self.authors = list(authors) if authors else []
- from calibre.ebooks.metadata.book.formatter import SafeFormat
+ from ebook_converter.ebooks.metadata.book.formatter import SafeFormat
self.formatter = SafeFormat() if formatter is None else formatter
self.template_cache = template_cache
@@ -441,7 +441,7 @@ class Metadata(object):
'''
if not ops:
return
- from calibre.ebooks.metadata.book.formatter import SafeFormat
+ from ebook_converter.ebooks.metadata.book.formatter import SafeFormat
formatter = SafeFormat()
for op in ops:
try:
@@ -584,14 +584,15 @@ class Metadata(object):
for attr in TOP_LEVEL_IDENTIFIERS:
copy_not_none(self, other, attr)
- other_lang = getattr(other, 'languages', [])
- if other_lang and other_lang != ['und']:
- self.languages = list(other_lang)
+ # other_lang = getattr(other, 'languages', [])
+ # if other_lang and other_lang != ['und']:
+ # self.languages = list(other_lang)
+ self.languages = []
if not getattr(self, 'series', None):
self.series_index = None
def format_series_index(self, val=None):
- from calibre.ebooks.metadata import fmt_sidx
+ from ebook_converter.ebooks.metadata import fmt_sidx
v = self.series_index if val is None else val
try:
x = float(v)
@@ -600,11 +601,11 @@ class Metadata(object):
return fmt_sidx(x)
def authors_from_string(self, raw):
- from calibre.ebooks.metadata import string_to_authors
+ from ebook_converter.ebooks.metadata import string_to_authors
self.authors = string_to_authors(raw)
def format_authors(self):
- from calibre.ebooks.metadata import authors_to_string
+ from ebook_converter.ebooks.metadata import authors_to_string
return authors_to_string(self.authors)
def format_tags(self):
@@ -625,12 +626,12 @@ class Metadata(object):
return (name, val)
def format_field_extended(self, key, series_with_index=True):
- from calibre.ebooks.metadata import authors_to_string
+ from ebook_converter.ebooks.metadata import authors_to_string
'''
returns the tuple (display_name, formatted_value, original_value,
field_metadata)
'''
- from calibre.utils.date import format_date
+ from ebook_converter.utils.date import format_date
# Handle custom series index
if key.startswith('#') and key.endswith('_index'):
@@ -715,8 +716,8 @@ class Metadata(object):
A string representation of this object, suitable for printing to
console
'''
- from calibre.utils.date import isoformat
- from calibre.ebooks.metadata import authors_to_string
+ from ebook_converter.utils.date import isoformat
+ from ebook_converter.ebooks.metadata import authors_to_string
ans = []
def fmt(x, y):
@@ -765,8 +766,8 @@ class Metadata(object):
'''
A HTML representation of this object.
'''
- from calibre.ebooks.metadata import authors_to_string
- from calibre.utils.date import isoformat
+ from ebook_converter.ebooks.metadata import authors_to_string
+ from ebook_converter.utils.date import isoformat
ans = [(_('Title'), unicode_type(self.title))]
ans += [(_('Author(s)'), (authors_to_string(self.authors) if self.authors else _('Unknown')))]
ans += [(_('Publisher'), unicode_type(self.publisher))]
@@ -817,7 +818,7 @@ def field_from_string(field, raw, field_metadata):
elif dt == 'rating':
val = float(raw) * 2
elif dt == 'datetime':
- from calibre.utils.date import parse_only_date
+ from ebook_converter.utils.date import parse_only_date
val = parse_only_date(raw)
elif dt == 'bool':
if raw.lower() in {'true', 'yes', 'y'}:
@@ -833,7 +834,7 @@ def field_from_string(field, raw, field_metadata):
if field == 'identifiers':
val = {x.partition(':')[0]:x.partition(':')[-1] for x in val}
elif field == 'languages':
- from calibre.utils.localization import canonicalize_lang
+ from ebook_converter.utils.localization import canonicalize_lang
val = [canonicalize_lang(x) for x in val]
val = [x for x in val if x]
if val is object:
diff --git a/ebook_converter/ebooks/metadata/book/formatter.py b/ebook_converter/ebooks/metadata/book/formatter.py
index 0943828..525e8f6 100644
--- a/ebook_converter/ebooks/metadata/book/formatter.py
+++ b/ebook_converter/ebooks/metadata/book/formatter.py
@@ -5,9 +5,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-from calibre.ebooks.metadata.book import TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS
+from ebook_converter.ebooks.metadata.book import TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS
-from calibre.utils.formatter import TemplateFormatter
+from ebook_converter.utils.formatter import TemplateFormatter
class SafeFormat(TemplateFormatter):
@@ -21,7 +21,7 @@ class SafeFormat(TemplateFormatter):
key = orig_key = orig_key.lower()
if (key != 'title_sort' and key not in TOP_LEVEL_IDENTIFIERS and
key not in ALL_METADATA_FIELDS):
- from calibre.ebooks.metadata.book.base import field_metadata
+ from ebook_converter.ebooks.metadata.book.base import field_metadata
key = field_metadata.search_term_to_field_key(key)
if key is None or (self.book and
key not in self.book.all_field_keys()):
diff --git a/ebook_converter/ebooks/metadata/book/json_codec.py b/ebook_converter/ebooks/metadata/book/json_codec.py
index 7df3b8b..a649fa5 100644
--- a/ebook_converter/ebooks/metadata/book/json_codec.py
+++ b/ebook_converter/ebooks/metadata/book/json_codec.py
@@ -9,19 +9,19 @@ Created on 4 Jun 2010
import json, traceback
from datetime import datetime, time
-from calibre.ebooks.metadata.book import SERIALIZABLE_FIELDS
-from calibre.constants import filesystem_encoding, preferred_encoding
-from calibre.library.field_metadata import FieldMetadata
-from calibre import isbytestring
-from polyglot.builtins import iteritems, itervalues, as_bytes
-from polyglot.binary import as_base64_unicode, from_base64_bytes
+from ebook_converter.ebooks.metadata.book import SERIALIZABLE_FIELDS
+from ebook_converter.constants import filesystem_encoding, preferred_encoding
+from ebook_converter.library.field_metadata import FieldMetadata
+from ebook_converter import isbytestring
+from ebook_converter.polyglot.builtins import iteritems, itervalues, as_bytes
+from ebook_converter.polyglot.binary import as_base64_unicode, from_base64_bytes
# Translate datetimes to and from strings. The string form is the datetime in
# UTC. The returned date is also UTC
def string_to_datetime(src):
- from calibre.utils.iso8601 import parse_iso8601
+ from ebook_converter.utils.iso8601 import parse_iso8601
if src != "None":
try:
return parse_iso8601(src)
@@ -31,7 +31,7 @@ def string_to_datetime(src):
def datetime_to_string(dateval):
- from calibre.utils.date import isoformat, UNDEFINED_DATE, local_tz
+ from ebook_converter.utils.date import isoformat, UNDEFINED_DATE, local_tz
if dateval is None:
return "None"
if not isinstance(dateval, datetime):
@@ -47,7 +47,7 @@ def encode_thumbnail(thumbnail):
'''
Encode the image part of a thumbnail, then return the 3 part tuple
'''
- from calibre.utils.imghdr import identify
+ from ebook_converter.utils.imghdr import identify
if thumbnail is None:
return None
if not isinstance(thumbnail, (tuple, list)):
diff --git a/ebook_converter/ebooks/metadata/html.py b/ebook_converter/ebooks/metadata/html.py
index 48408bc..55db29c 100644
--- a/ebook_converter/ebooks/metadata/html.py
+++ b/ebook_converter/ebooks/metadata/html.py
@@ -15,12 +15,12 @@ from collections import defaultdict
from html5_parser import parse
from lxml.etree import Comment
-from calibre.ebooks.metadata import string_to_authors, authors_to_string
-from calibre.ebooks.metadata.book.base import Metadata
-from calibre.ebooks.chardet import xml_to_unicode
-from calibre import replace_entities, isbytestring
-from calibre.utils.date import parse_date, is_date_undefined
-from polyglot.builtins import iteritems
+from ebook_converter.ebooks.metadata import string_to_authors, authors_to_string
+from ebook_converter.ebooks.metadata.book.base import Metadata
+from ebook_converter.ebooks.chardet import xml_to_unicode
+from ebook_converter import replace_entities, isbytestring
+from ebook_converter.utils.date import parse_date, is_date_undefined
+from ebook_converter.polyglot.builtins import iteritems
def get_metadata(stream):
diff --git a/ebook_converter/ebooks/metadata/meta.py b/ebook_converter/ebooks/metadata/meta.py
index f1dcc5d..15f14c9 100644
--- a/ebook_converter/ebooks/metadata/meta.py
+++ b/ebook_converter/ebooks/metadata/meta.py
@@ -5,13 +5,13 @@ __copyright__ = '2008, Kovid Goyal '
import os, re, collections
-from calibre.utils.config import prefs
-from calibre.constants import filesystem_encoding
-from calibre.ebooks.metadata.opf2 import OPF
-from calibre import isbytestring
-from calibre.customize.ui import get_file_type_metadata, set_file_type_metadata
-from calibre.ebooks.metadata import MetaInformation, string_to_authors
-from polyglot.builtins import getcwd, unicode_type
+from ebook_converter.utils.config import prefs
+from ebook_converter.constants import filesystem_encoding
+from ebook_converter.ebooks.metadata.opf2 import OPF
+from ebook_converter import isbytestring
+from ebook_converter.customize.ui import get_file_type_metadata, set_file_type_metadata
+from ebook_converter.ebooks.metadata import MetaInformation, string_to_authors
+from ebook_converter.polyglot.builtins import getcwd, unicode_type
# The priorities for loading metadata from different file types
# Higher values should be used to update metadata from lower values
@@ -184,7 +184,7 @@ def metadata_from_filename(name, pat=None, fallback_pat=None):
try:
pubdate = match.group('published')
if pubdate:
- from calibre.utils.date import parse_only_date
+ from ebook_converter.utils.date import parse_only_date
mi.pubdate = parse_only_date(pubdate)
except:
pass
@@ -224,7 +224,7 @@ def opf_metadata(opfpath):
def forked_read_metadata(path, tdir):
- from calibre.ebooks.metadata.opf2 import metadata_to_opf
+ from ebook_converter.ebooks.metadata.opf2 import metadata_to_opf
with lopen(path, 'rb') as f:
fmt = os.path.splitext(path)[1][1:].lower()
f.seek(0, 2)
diff --git a/ebook_converter/ebooks/metadata/odt.py b/ebook_converter/ebooks/metadata/odt.py
index 71258d6..ab324f5 100644
--- a/ebook_converter/ebooks/metadata/odt.py
+++ b/ebook_converter/ebooks/metadata/odt.py
@@ -27,17 +27,17 @@ import re
from lxml.etree import fromstring, tostring
-from calibre.ebooks.metadata import (
+from ebook_converter.ebooks.metadata import (
MetaInformation, authors_to_string, check_isbn, string_to_authors
)
-from calibre.utils.date import isoformat, parse_date
-from calibre.utils.imghdr import identify
-from calibre.utils.localization import canonicalize_lang, lang_as_iso639_1
-from calibre.utils.zipfile import ZipFile, safe_replace
+from ebook_converter.utils.date import isoformat, parse_date
+from ebook_converter.utils.imghdr import identify
+from ebook_converter.utils.localization import canonicalize_lang, lang_as_iso639_1
+from ebook_converter.utils.zipfile import ZipFile, safe_replace
from odf.draw import Frame as odFrame, Image as odImage
from odf.namespaces import DCNS, METANS, OFFICENS
from odf.opendocument import load as odLoad
-from polyglot.builtins import as_unicode
+from ebook_converter.polyglot.builtins import as_unicode
fields = {
'title': (DCNS, 'title'),
diff --git a/ebook_converter/ebooks/metadata/opf2.py b/ebook_converter/ebooks/metadata/opf2.py
index 9aeee85..3fb8ed5 100644
--- a/ebook_converter/ebooks/metadata/opf2.py
+++ b/ebook_converter/ebooks/metadata/opf2.py
@@ -12,20 +12,20 @@ import re, sys, unittest, functools, os, uuid, glob, io, json, copy
from lxml import etree
-from calibre.ebooks import escape_xpath_attr
-from calibre.constants import __appname__, __version__, filesystem_encoding, ispy3
-from calibre.ebooks.metadata.toc import TOC
-from calibre.ebooks.metadata.utils import parse_opf, pretty_print_opf as _pretty_print
-from calibre.ebooks.metadata import string_to_authors, MetaInformation, check_isbn
-from calibre.ebooks.metadata.book.base import Metadata
-from calibre.utils.date import parse_date, isoformat
-from calibre.utils.localization import get_lang, canonicalize_lang
-from calibre import prints, guess_type
-from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
-from calibre.utils.config import tweaks
-from calibre.utils.xml_parse import safe_xml_fromstring
-from polyglot.builtins import iteritems, unicode_type, getcwd, map
-from polyglot.urllib import unquote, urlparse
+from ebook_converter.ebooks import escape_xpath_attr
+from ebook_converter.constants import __appname__, __version__, filesystem_encoding, ispy3
+from ebook_converter.ebooks.metadata.toc import TOC
+from ebook_converter.ebooks.metadata.utils import parse_opf, pretty_print_opf as _pretty_print
+from ebook_converter.ebooks.metadata import string_to_authors, MetaInformation, check_isbn
+from ebook_converter.ebooks.metadata.book.base import Metadata
+from ebook_converter.utils.date import parse_date, isoformat
+from ebook_converter.utils.localization import get_lang, canonicalize_lang
+from ebook_converter import prints, guess_type
+from ebook_converter.utils.cleantext import clean_ascii_chars, clean_xml_chars
+from ebook_converter.utils.config import tweaks
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, getcwd, map
+from ebook_converter.polyglot.urllib import unquote, urlparse
pretty_print_opf = False
@@ -487,8 +487,8 @@ class TitleSortField(MetadataField):
def serialize_user_metadata(metadata_elem, all_user_metadata, tail='\n'+(' '*8)):
- from calibre.utils.config import to_json
- from calibre.ebooks.metadata.book.json_codec import (object_to_unicode,
+ from ebook_converter.utils.config import to_json
+ from ebook_converter.ebooks.metadata.book.json_codec import (object_to_unicode,
encode_is_multiple)
for name, fm in all_user_metadata.items():
@@ -512,7 +512,7 @@ def serialize_user_metadata(metadata_elem, all_user_metadata, tail='\n'+(' '*8))
def dump_dict(cats):
if not cats:
cats = {}
- from calibre.ebooks.metadata.book.json_codec import object_to_unicode
+ from ebook_converter.ebooks.metadata.book.json_codec import object_to_unicode
return json.dumps(object_to_unicode(cats), ensure_ascii=False,
skipkeys=True)
@@ -620,8 +620,8 @@ class OPF(object): # {{{
def read_user_metadata(self):
self._user_metadata_ = {}
temp = Metadata('x', ['x'])
- from calibre.utils.config import from_json
- from calibre.ebooks.metadata.book.json_codec import decode_is_multiple
+ from ebook_converter.utils.config import from_json
+ from ebook_converter.ebooks.metadata.book.json_codec import decode_is_multiple
elems = self.root.xpath('//*[name() = "meta" and starts-with(@name,'
'"calibre:user_metadata:") and @content]')
for elem in elems:
@@ -643,7 +643,7 @@ class OPF(object): # {{{
def to_book_metadata(self):
if self.package_version >= 3.0:
- from calibre.ebooks.metadata.opf3 import read_metadata
+ from ebook_converter.ebooks.metadata.opf3 import read_metadata
return read_metadata(self.root)
ans = MetaInformation(self)
for n, v in self._user_metadata_.items():
@@ -964,7 +964,7 @@ class OPF(object): # {{{
found_scheme = False
for attr, val in iteritems(x.attrib):
if attr.endswith('scheme'):
- typ = icu_lower(val)
+ typ = val.lower()
val = etree.tostring(x, with_tail=False, encoding='unicode',
method='text').strip()
if val and typ not in ('calibre', 'uuid'):
@@ -1447,7 +1447,7 @@ class OPFCreator(Metadata):
# Actual rendering
from lxml.builder import ElementMaker
- from calibre.ebooks.oeb.base import OPF2_NS, DC11_NS, CALIBRE_NS
+ from ebook_converter.ebooks.oeb.base import OPF2_NS, DC11_NS, CALIBRE_NS
DNS = OPF2_NS+'___xx___'
E = ElementMaker(namespace=DNS, nsmap={None:DNS})
M = ElementMaker(namespace=DNS,
@@ -1494,7 +1494,7 @@ class OPFCreator(Metadata):
if self.publisher:
a(DC_ELEM('publisher', self.publisher))
for key, val in iteritems(self.get_identifiers()):
- a(DC_ELEM('identifier', val, opf_attrs={'scheme':icu_upper(key)}))
+ a(DC_ELEM('identifier', val, opf_attrs={'scheme':key.upper()}))
if self.rights:
a(DC_ELEM('rights', self.rights))
if self.tags:
@@ -1513,7 +1513,7 @@ class OPFCreator(Metadata):
if self.publication_type is not None:
a(CAL_ELEM('calibre:publication_type', self.publication_type))
if self.user_categories:
- from calibre.ebooks.metadata.book.json_codec import object_to_unicode
+ from ebook_converter.ebooks.metadata.book.json_codec import object_to_unicode
a(CAL_ELEM('calibre:user_categories',
json.dumps(object_to_unicode(self.user_categories))))
if self.primary_writing_mode:
@@ -1572,7 +1572,7 @@ class OPFCreator(Metadata):
def metadata_to_opf(mi, as_string=True, default_lang=None):
from lxml import etree
import textwrap
- from calibre.ebooks.oeb.base import OPF, DC
+ from ebook_converter.ebooks.oeb.base import OPF, DC
if not mi.application_id:
mi.application_id = unicode_type(uuid.uuid4())
@@ -1641,7 +1641,7 @@ def metadata_to_opf(mi, as_string=True, default_lang=None):
if mi.publisher:
factory(DC('publisher'), mi.publisher)
for key, val in iteritems(mi.get_identifiers()):
- factory(DC('identifier'), val, scheme=icu_upper(key))
+ factory(DC('identifier'), val, scheme=key.upper())
if mi.rights:
factory(DC('rights'), mi.rights)
for lang in mi.languages:
@@ -1689,7 +1689,7 @@ def metadata_to_opf(mi, as_string=True, default_lang=None):
def test_m2o():
- from calibre.utils.date import now as nowf
+ from ebook_converter.utils.date import now as nowf
mi = MetaInformation('test & title', ['a"1', "a'2"])
mi.title_sort = 'a\'"b'
mi.author_sort = 'author sort'
diff --git a/ebook_converter/ebooks/metadata/opf3.py b/ebook_converter/ebooks/metadata/opf3.py
index 509f45b..5bdae96 100644
--- a/ebook_converter/ebooks/metadata/opf3.py
+++ b/ebook_converter/ebooks/metadata/opf3.py
@@ -8,28 +8,28 @@ import json
import re
from collections import defaultdict, namedtuple
from functools import wraps
-from polyglot.builtins import iteritems, map, filter
+from ebook_converter.polyglot.builtins import iteritems, map, filter
from lxml import etree
-from calibre import prints
-from calibre.ebooks.metadata import authors_to_string, check_isbn, string_to_authors
-from calibre.ebooks.metadata.book.base import Metadata
-from calibre.ebooks.metadata.book.json_codec import (
+from ebook_converter import prints
+from ebook_converter.ebooks.metadata import authors_to_string, check_isbn, string_to_authors
+from ebook_converter.ebooks.metadata.book.base import Metadata
+from ebook_converter.ebooks.metadata.book.json_codec import (
decode_is_multiple, encode_is_multiple, object_to_unicode
)
-from calibre.ebooks.metadata.utils import (
+from ebook_converter.ebooks.metadata.utils import (
create_manifest_item, ensure_unique, normalize_languages, parse_opf,
pretty_print_opf
)
-from calibre.ebooks.oeb.base import DC, OPF, OPF2_NSMAP
-from calibre.utils.config import from_json, to_json
-from calibre.utils.date import (
+from ebook_converter.ebooks.oeb.base import DC, OPF, OPF2_NSMAP
+from ebook_converter.utils.config import from_json, to_json
+from ebook_converter.utils.date import (
fix_only_date, is_date_undefined, isoformat, parse_date as parse_date_, utcnow,
w3cdtf
)
-from calibre.utils.iso8601 import parse_iso8601
-from calibre.utils.localization import canonicalize_lang
+from ebook_converter.utils.iso8601 import parse_iso8601
+from ebook_converter.utils.localization import canonicalize_lang
# Utils {{{
_xpath_cache = {}
diff --git a/ebook_converter/ebooks/metadata/rtf.py b/ebook_converter/ebooks/metadata/rtf.py
index d208436..61118f3 100644
--- a/ebook_converter/ebooks/metadata/rtf.py
+++ b/ebook_converter/ebooks/metadata/rtf.py
@@ -9,9 +9,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import codecs
import re
-from calibre import force_unicode
-from calibre.ebooks.metadata import MetaInformation
-from polyglot.builtins import codepoint_to_chr, string_or_bytes, unicode_type, int_to_byte, filter
+from ebook_converter import force_unicode
+from ebook_converter.ebooks.metadata import MetaInformation
+from ebook_converter.polyglot.builtins import codepoint_to_chr, string_or_bytes, unicode_type, int_to_byte, filter
title_pat = re.compile(br'\{\\info.*?\{\\title(.*?)(?'
-__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/ebook_converter/ebooks/mobi/reader/containers.py b/ebook_converter/ebooks/mobi/reader/containers.py
index 336ca5f..4462b11 100644
--- a/ebook_converter/ebooks/mobi/reader/containers.py
+++ b/ebook_converter/ebooks/mobi/reader/containers.py
@@ -7,7 +7,7 @@ __copyright__ = '2014, Kovid Goyal '
from struct import unpack_from, error
-from calibre.utils.imghdr import what
+from ebook_converter.utils.imghdr import what
def find_imgtype(data):
diff --git a/ebook_converter/ebooks/mobi/reader/headers.py b/ebook_converter/ebooks/mobi/reader/headers.py
index c164b95..ace9ddc 100644
--- a/ebook_converter/ebooks/mobi/reader/headers.py
+++ b/ebook_converter/ebooks/mobi/reader/headers.py
@@ -8,15 +8,15 @@ __docformat__ = 'restructuredtext en'
import struct, re, os
-from calibre import replace_entities
-from calibre.utils.date import parse_date
-from calibre.ebooks.mobi import MobiError
-from calibre.ebooks.metadata import MetaInformation, check_isbn
-from calibre.ebooks.mobi.langcodes import main_language, sub_language, mobi2iana
-from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
-from calibre.utils.localization import canonicalize_lang
-from calibre.utils.config_base import tweaks
-from polyglot.builtins import unicode_type
+from ebook_converter import replace_entities
+from ebook_converter.utils.date import parse_date
+from ebook_converter.ebooks.mobi import MobiError
+from ebook_converter.ebooks.metadata import MetaInformation, check_isbn
+from ebook_converter.ebooks.mobi.langcodes import main_language, sub_language, mobi2iana
+from ebook_converter.utils.cleantext import clean_ascii_chars, clean_xml_chars
+from ebook_converter.utils.localization import canonicalize_lang
+from ebook_converter.utils.config_base import tweaks
+from ebook_converter.polyglot.builtins import unicode_type
NULL_INDEX = 0xffffffff
diff --git a/ebook_converter/ebooks/mobi/reader/index.py b/ebook_converter/ebooks/mobi/reader/index.py
index 78c5c9a..9a14538 100644
--- a/ebook_converter/ebooks/mobi/reader/index.py
+++ b/ebook_converter/ebooks/mobi/reader/index.py
@@ -9,9 +9,9 @@ __docformat__ = 'restructuredtext en'
import struct
from collections import OrderedDict, namedtuple
-from calibre.ebooks.mobi.utils import (decint, count_set_bits,
+from ebook_converter.ebooks.mobi.utils import (decint, count_set_bits,
decode_string)
-from polyglot.builtins import iteritems, range, zip
+from ebook_converter.polyglot.builtins import iteritems, range, zip
TagX = namedtuple('TagX', 'tag num_of_values bitmask eof')
PTagX = namedtuple('PTagX', 'tag value_count value_bytes num_of_values')
diff --git a/ebook_converter/ebooks/mobi/reader/markup.py b/ebook_converter/ebooks/mobi/reader/markup.py
index 097d66f..ca8fcf6 100644
--- a/ebook_converter/ebooks/mobi/reader/markup.py
+++ b/ebook_converter/ebooks/mobi/reader/markup.py
@@ -8,8 +8,8 @@ __docformat__ = 'restructuredtext en'
import re, os
-from calibre.ebooks.chardet import strip_encoding_declarations
-from polyglot.builtins import unicode_type, range
+from ebook_converter.ebooks.chardet import strip_encoding_declarations
+from ebook_converter.polyglot.builtins import unicode_type, range
def update_internal_links(mobi8_reader, log):
diff --git a/ebook_converter/ebooks/mobi/reader/mobi6.py b/ebook_converter/ebooks/mobi/reader/mobi6.py
index ebd54e3..4f1ddf7 100644
--- a/ebook_converter/ebooks/mobi/reader/mobi6.py
+++ b/ebook_converter/ebooks/mobi/reader/mobi6.py
@@ -10,20 +10,20 @@ import shutil, os, re, struct, textwrap, io
from lxml import html, etree
-from calibre import xml_entity_to_unicode, entity_to_unicode, guess_type
-from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
-from calibre.ebooks import DRMError, unit_convert
-from calibre.ebooks.chardet import strip_encoding_declarations
-from calibre.ebooks.mobi import MobiError
-from calibre.ebooks.mobi.huffcdic import HuffReader
-from calibre.ebooks.compression.palmdoc import decompress_doc
-from calibre.ebooks.metadata import MetaInformation
-from calibre.ebooks.metadata.opf2 import OPFCreator, OPF
-from calibre.ebooks.metadata.toc import TOC
-from calibre.ebooks.mobi.reader.headers import BookHeader
-from calibre.utils.img import save_cover_data_to, gif_data_to_png_data, AnimatedGIF
-from calibre.utils.imghdr import what
-from polyglot.builtins import iteritems, unicode_type, range, map
+from ebook_converter import xml_entity_to_unicode, entity_to_unicode, guess_type
+from ebook_converter.utils.cleantext import clean_ascii_chars, clean_xml_chars
+from ebook_converter.ebooks import DRMError, unit_convert
+from ebook_converter.ebooks.chardet import strip_encoding_declarations
+from ebook_converter.ebooks.mobi import MobiError
+from ebook_converter.ebooks.mobi.huffcdic import HuffReader
+from ebook_converter.ebooks.compression.palmdoc import decompress_doc
+from ebook_converter.ebooks.metadata import MetaInformation
+from ebook_converter.ebooks.metadata.opf2 import OPFCreator, OPF
+from ebook_converter.ebooks.metadata.toc import TOC
+from ebook_converter.ebooks.mobi.reader.headers import BookHeader
+from ebook_converter.utils.img import save_cover_data_to, gif_data_to_png_data, AnimatedGIF
+from ebook_converter.utils.imghdr import what
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, range, map
class TopazError(ValueError):
diff --git a/ebook_converter/ebooks/mobi/reader/mobi8.py b/ebook_converter/ebooks/mobi/reader/mobi8.py
index 0d03720..ad4cca1 100644
--- a/ebook_converter/ebooks/mobi/reader/mobi8.py
+++ b/ebook_converter/ebooks/mobi/reader/mobi8.py
@@ -13,18 +13,18 @@ from uuid import uuid4
from lxml import etree
-from calibre.ebooks.mobi.reader.headers import NULL_INDEX
-from calibre.ebooks.mobi.reader.index import read_index
-from calibre.ebooks.mobi.reader.ncx import read_ncx, build_toc
-from calibre.ebooks.mobi.reader.markup import expand_mobi8_markup
-from calibre.ebooks.mobi.reader.containers import Container, find_imgtype
-from calibre.ebooks.metadata.opf2 import Guide, OPFCreator
-from calibre.ebooks.metadata.toc import TOC
-from calibre.ebooks.mobi.utils import read_font_record
-from calibre.ebooks.oeb.parse_utils import parse_html
-from calibre.ebooks.oeb.base import XPath, XHTML, xml2text
-from polyglot.builtins import range, zip, unicode_type, getcwd, as_unicode
-from polyglot.urllib import urldefrag
+from ebook_converter.ebooks.mobi.reader.headers import NULL_INDEX
+from ebook_converter.ebooks.mobi.reader.index import read_index
+from ebook_converter.ebooks.mobi.reader.ncx import read_ncx, build_toc
+from ebook_converter.ebooks.mobi.reader.markup import expand_mobi8_markup
+from ebook_converter.ebooks.mobi.reader.containers import Container, find_imgtype
+from ebook_converter.ebooks.metadata.opf2 import Guide, OPFCreator
+from ebook_converter.ebooks.metadata.toc import TOC
+from ebook_converter.ebooks.mobi.utils import read_font_record
+from ebook_converter.ebooks.oeb.parse_utils import parse_html
+from ebook_converter.ebooks.oeb.base import XPath, XHTML, xml2text
+from ebook_converter.polyglot.builtins import range, zip, unicode_type, getcwd, as_unicode
+from ebook_converter.polyglot.urllib import urldefrag
Part = namedtuple('Part',
'num type filename start end aid')
@@ -411,7 +411,7 @@ class Mobi8Reader(object):
return build_toc(index_entries)
def extract_resources(self, sections):
- from calibre.ebooks.mobi.writer2.resources import PLACEHOLDER_GIF
+ from ebook_converter.ebooks.mobi.writer2.resources import PLACEHOLDER_GIF
resource_map = []
container = None
for x in ('fonts', 'images'):
diff --git a/ebook_converter/ebooks/mobi/reader/ncx.py b/ebook_converter/ebooks/mobi/reader/ncx.py
index 6f49e1c..83cacb3 100644
--- a/ebook_converter/ebooks/mobi/reader/ncx.py
+++ b/ebook_converter/ebooks/mobi/reader/ncx.py
@@ -6,11 +6,11 @@ __license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre import replace_entities
-from calibre.ebooks.metadata.toc import TOC
-from calibre.ebooks.mobi.reader.headers import NULL_INDEX
-from calibre.ebooks.mobi.reader.index import read_index
-from polyglot.builtins import iteritems, getcwd
+from ebook_converter import replace_entities
+from ebook_converter.ebooks.metadata.toc import TOC
+from ebook_converter.ebooks.mobi.reader.headers import NULL_INDEX
+from ebook_converter.ebooks.mobi.reader.index import read_index
+from ebook_converter.polyglot.builtins import iteritems, getcwd
tag_fieldname_map = {
1: ['pos',0],
diff --git a/ebook_converter/ebooks/mobi/tweak.py b/ebook_converter/ebooks/mobi/tweak.py
index 82ee5f5..5e27af7 100644
--- a/ebook_converter/ebooks/mobi/tweak.py
+++ b/ebook_converter/ebooks/mobi/tweak.py
@@ -8,17 +8,17 @@ __docformat__ = 'restructuredtext en'
import os, glob
-from calibre import CurrentDir
-from calibre.ebooks.mobi import MobiError
-from calibre.ebooks.mobi.reader.mobi6 import MobiReader
-from calibre.ebooks.mobi.reader.headers import MetadataHeader
-from calibre.utils.logging import default_log
-from calibre.ebooks import DRMError
-from calibre.ebooks.mobi.reader.mobi8 import Mobi8Reader
-from calibre.ebooks.conversion.plumber import Plumber, create_oebbook
-from calibre.customize.ui import (plugin_for_input_format,
+from ebook_converter import CurrentDir
+from ebook_converter.ebooks.mobi import MobiError
+from ebook_converter.ebooks.mobi.reader.mobi6 import MobiReader
+from ebook_converter.ebooks.mobi.reader.headers import MetadataHeader
+from ebook_converter.utils.logging import default_log
+from ebook_converter.ebooks import DRMError
+from ebook_converter.ebooks.mobi.reader.mobi8 import Mobi8Reader
+from ebook_converter.ebooks.conversion.plumber import Plumber, create_oebbook
+from ebook_converter.customize.ui import (plugin_for_input_format,
plugin_for_output_format)
-from calibre.utils.ipc.simple_worker import fork_job
+from ebook_converter.utils.ipc.simple_worker import fork_job
class BadFormat(ValueError):
@@ -70,7 +70,7 @@ def explode(path, dest, question=lambda x:True):
'sure?')):
return None
- return fork_job('calibre.ebooks.mobi.tweak', 'do_explode', args=(path,
+ return fork_job('ebook_converter.ebooks.mobi.tweak', 'do_explode', args=(path,
dest), no_output=True)['result']
@@ -104,6 +104,6 @@ def rebuild(src_dir, dest_path):
# For debugging, uncomment the following two lines
# def fork_job(a, b, args=None, no_output=True):
# do_rebuild(*args)
- fork_job('calibre.ebooks.mobi.tweak', 'do_rebuild', args=(opf, dest_path),
+ fork_job('ebook_converter.ebooks.mobi.tweak', 'do_rebuild', args=(opf, dest_path),
no_output=True)
diff --git a/ebook_converter/ebooks/mobi/utils.py b/ebook_converter/ebooks/mobi/utils.py
index 0121777..fab0632 100644
--- a/ebook_converter/ebooks/mobi/utils.py
+++ b/ebook_converter/ebooks/mobi/utils.py
@@ -10,10 +10,10 @@ import struct, string, zlib, os
from collections import OrderedDict
from io import BytesIO
-from calibre.utils.img import save_cover_data_to, scale_image, image_to_data, image_from_data, resize_image, png_data_to_gif_data
-from calibre.utils.imghdr import what
-from calibre.ebooks import normalize
-from polyglot.builtins import unicode_type, range, as_bytes, map
+from ebook_converter.utils.img import save_cover_data_to, scale_image, image_to_data, image_from_data, resize_image, png_data_to_gif_data
+from ebook_converter.utils.imghdr import what
+from ebook_converter.ebooks import normalize
+from ebook_converter.polyglot.builtins import unicode_type, range, as_bytes, map
from tinycss.color3 import parse_color_string
IMAGE_MAX_SIZE = 10 * 1024 * 1024
diff --git a/ebook_converter/ebooks/mobi/writer2/resources.py b/ebook_converter/ebooks/mobi/writer2/resources.py
index 7db0fe3..90b70ac 100644
--- a/ebook_converter/ebooks/mobi/writer2/resources.py
+++ b/ebook_converter/ebooks/mobi/writer2/resources.py
@@ -8,14 +8,14 @@ __docformat__ = 'restructuredtext en'
import os
-from calibre.ebooks.mobi import MAX_THUMB_DIMEN, MAX_THUMB_SIZE
-from calibre.ebooks.mobi.utils import (rescale_image, mobify_image,
+from ebook_converter.ebooks.mobi import MAX_THUMB_DIMEN, MAX_THUMB_SIZE
+from ebook_converter.ebooks.mobi.utils import (rescale_image, mobify_image,
write_font_record)
-from calibre.ebooks import generate_masthead
-from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
-from calibre.ptempfile import PersistentTemporaryFile
-from calibre.utils.imghdr import what
-from polyglot.builtins import iteritems, unicode_type
+from ebook_converter.ebooks import generate_masthead
+from ebook_converter.ebooks.oeb.base import OEB_RASTER_IMAGES
+from ebook_converter.ptempfile import PersistentTemporaryFile
+from ebook_converter.utils.imghdr import what
+from ebook_converter.polyglot.builtins import iteritems, unicode_type
PLACEHOLDER_GIF = b'GIF89a\x01\x00\x01\x00\xf0\x00\x00\x00\x00\x00\xff\xff\xff!\xf9\x04\x01\x00\x00\x00\x00!\xfe calibre-placeholder-gif-for-azw3\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;' # noqa
@@ -51,7 +51,7 @@ class Resources(object):
with PersistentTemporaryFile(suffix='.png') as pt:
pt.write(data)
try:
- from calibre.utils.img import optimize_png
+ from ebook_converter.utils.img import optimize_png
optimize_png(pt.name)
data = lopen(pt.name, 'rb').read()
finally:
diff --git a/ebook_converter/ebooks/odt/__init__.py b/ebook_converter/ebooks/odt/__init__.py
index 8a2513c..e69de29 100644
--- a/ebook_converter/ebooks/odt/__init__.py
+++ b/ebook_converter/ebooks/odt/__init__.py
@@ -1,10 +0,0 @@
-#!/usr/bin/env python2
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
-__docformat__ = 'restructuredtext en'
-
-'''
-Handle the Open Document Format
-'''
diff --git a/ebook_converter/ebooks/odt/input.py b/ebook_converter/ebooks/odt/input.py
index 00121cf..23a8a69 100644
--- a/ebook_converter/ebooks/odt/input.py
+++ b/ebook_converter/ebooks/odt/input.py
@@ -17,10 +17,10 @@ from odf.opendocument import load as odLoad
from odf.draw import Frame as odFrame, Image as odImage
from odf.namespaces import TEXTNS as odTEXTNS
-from calibre import CurrentDir, walk
-from calibre.ebooks.oeb.base import _css_logger
-from calibre.utils.xml_parse import safe_xml_fromstring
-from polyglot.builtins import unicode_type, string_or_bytes, filter, getcwd, as_bytes
+from ebook_converter import CurrentDir, walk
+from ebook_converter.ebooks.oeb.base import _css_logger
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, filter, getcwd, as_bytes
class Extract(ODF2XHTML):
@@ -88,7 +88,7 @@ class Extract(ODF2XHTML):
return rule
def epubify_markup(self, root, log):
- from calibre.ebooks.oeb.base import XPath, XHTML
+ from ebook_converter.ebooks.oeb.base import XPath, XHTML
# Fix empty title tags
for t in XPath('//h:title')(root):
if not t.text:
@@ -265,9 +265,9 @@ class Extract(ODF2XHTML):
self._walknode(self.document.topnode)
def __call__(self, stream, odir, log):
- from calibre.utils.zipfile import ZipFile
- from calibre.ebooks.metadata.odt import get_metadata
- from calibre.ebooks.metadata.opf2 import OPFCreator
+ from ebook_converter.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.metadata.odt import get_metadata
+ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
if not os.path.exists(odir):
os.makedirs(odir)
diff --git a/ebook_converter/ebooks/oeb/__init__.py b/ebook_converter/ebooks/oeb/__init__.py
index 57af319..e69de29 100644
--- a/ebook_converter/ebooks/oeb/__init__.py
+++ b/ebook_converter/ebooks/oeb/__init__.py
@@ -1,4 +0,0 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2008, Marshall T. Vandegrift '
diff --git a/ebook_converter/ebooks/oeb/base.py b/ebook_converter/ebooks/oeb/base.py
index e415d0a..9dad0c1 100644
--- a/ebook_converter/ebooks/oeb/base.py
+++ b/ebook_converter/ebooks/oeb/base.py
@@ -13,19 +13,18 @@ from itertools import count
from operator import attrgetter
from lxml import etree, html
-from calibre import force_unicode
-from calibre.constants import filesystem_encoding, __version__, ispy3
-from calibre.translations.dynamic import translate
-from calibre.utils.xml_parse import safe_xml_fromstring
-from calibre.ebooks.chardet import xml_to_unicode
-from calibre.ebooks.conversion.preprocess import CSSPreProcessor
-from calibre import (isbytestring, as_unicode, get_types_map)
-from calibre.ebooks.oeb.parse_utils import barename, XHTML_NS, namespace, XHTML, parse_html, NotHTML
-from calibre.utils.cleantext import clean_xml_chars
-from calibre.utils.short_uuid import uuid4
-from polyglot.builtins import iteritems, unicode_type, string_or_bytes, range, itervalues, filter, codepoint_to_chr
-from polyglot.urllib import unquote as urlunquote, urldefrag, urljoin, urlparse, urlunparse
-from calibre.utils.icu import numeric_sort_key
+from ebook_converter import force_unicode
+from ebook_converter.constants import filesystem_encoding, __version__, ispy3
+from ebook_converter.translations.dynamic import translate
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.ebooks.chardet import xml_to_unicode
+from ebook_converter.ebooks.conversion.preprocess import CSSPreProcessor
+from ebook_converter import (isbytestring, as_unicode, get_types_map)
+from ebook_converter.ebooks.oeb.parse_utils import barename, XHTML_NS, namespace, XHTML, parse_html, NotHTML
+from ebook_converter.utils.cleantext import clean_xml_chars
+from ebook_converter.utils.short_uuid import uuid4
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, range, itervalues, filter, codepoint_to_chr
+from ebook_converter.polyglot.urllib import unquote as urlunquote, urldefrag, urljoin, urlparse, urlunparse
XML_NS = 'http://www.w3.org/XML/1998/namespace'
OEB_DOC_NS = 'http://openebook.org/namespaces/oeb-document/1.0/'
@@ -971,7 +970,7 @@ class Manifest(object):
self.oeb.log.debug('Converting', self.href, '...')
- from calibre.ebooks.txt.processor import convert_markdown
+ from ebook_converter.ebooks.txt.processor import convert_markdown
title = self.oeb.metadata.title
if title:
@@ -1064,7 +1063,7 @@ class Manifest(object):
def unload_data_from_memory(self, memory=None):
if isinstance(self._data, bytes):
if memory is None:
- from calibre.ptempfile import PersistentTemporaryFile
+ from ebook_converter.ptempfile import PersistentTemporaryFile
pt = PersistentTemporaryFile(suffix='_oeb_base_mem_unloader.img')
with pt:
pt.write(self._data)
@@ -1124,7 +1123,8 @@ class Manifest(object):
if isinstance(href, bytes):
href = force_unicode(href)
sp = self.spine_position if isinstance(self.spine_position, numbers.Number) else sys.maxsize
- return sp, (self.media_type or '').lower(), numeric_sort_key(href), self.id
+
+ return sp, (self.media_type or '').lower(), href, self.id
def relhref(self, href):
"""Convert the URL provided in :param:`href` from a book-absolute
diff --git a/ebook_converter/ebooks/oeb/normalize_css.py b/ebook_converter/ebooks/oeb/normalize_css.py
index c550bd4..87f332b 100644
--- a/ebook_converter/ebooks/oeb/normalize_css.py
+++ b/ebook_converter/ebooks/oeb/normalize_css.py
@@ -10,9 +10,9 @@ from functools import wraps
from css_parser.css import PropertyValue
from css_parser import profile as cssprofiles, CSSParser
-from tinycss.fonts3 import parse_font, serialize_font_family
-from calibre.ebooks.oeb.base import css_text
-from polyglot.builtins import iteritems, string_or_bytes, unicode_type, zip
+from ebook_converter.tinycss.fonts3 import parse_font, serialize_font_family
+from ebook_converter.ebooks.oeb.base import css_text
+from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, unicode_type, zip
DEFAULTS = {'azimuth': 'center', 'background-attachment': 'scroll', # {{{
'background-color': 'transparent', 'background-image': 'none',
diff --git a/ebook_converter/ebooks/oeb/parse_utils.py b/ebook_converter/ebooks/oeb/parse_utils.py
index 0db0bc7..b0dab4e 100644
--- a/ebook_converter/ebooks/oeb/parse_utils.py
+++ b/ebook_converter/ebooks/oeb/parse_utils.py
@@ -10,11 +10,11 @@ import re
from lxml import etree, html
-from calibre import xml_replace_entities, force_unicode
-from calibre.utils.xml_parse import safe_xml_fromstring
-from calibre.constants import filesystem_encoding
-from calibre.ebooks.chardet import xml_to_unicode, strip_encoding_declarations
-from polyglot.builtins import iteritems, itervalues, unicode_type, string_or_bytes, map
+from ebook_converter import xml_replace_entities, force_unicode
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.constants import filesystem_encoding
+from ebook_converter.ebooks.chardet import xml_to_unicode, strip_encoding_declarations
+from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, string_or_bytes, map
RECOVER_PARSER = etree.XMLParser(recover=True, no_network=True, resolve_entities=False)
XHTML_NS = 'http://www.w3.org/1999/xhtml'
@@ -94,7 +94,7 @@ def node_depth(node):
def html5_parse(data, max_nesting_depth=100):
from html5_parser import parse
- from calibre.utils.cleantext import clean_xml_chars
+ from ebook_converter.utils.cleantext import clean_xml_chars
data = parse(clean_xml_chars(data), maybe_xhtml=True, keep_doctype=False, sanitize_names=True)
# Check that the asinine HTML 5 algorithm did not result in a tree with
# insane nesting depths
@@ -160,7 +160,7 @@ def check_for_html5(prefix, root):
def parse_html(data, log=None, decoder=None, preprocessor=None,
filename='', non_html_file_tags=frozenset()):
if log is None:
- from calibre.utils.logging import default_log
+ from ebook_converter.utils.logging import default_log
log = default_log
filename = force_unicode(filename, enc=filesystem_encoding)
diff --git a/ebook_converter/ebooks/oeb/polish/__init__.py b/ebook_converter/ebooks/oeb/polish/__init__.py
index 64be92c..e69de29 100644
--- a/ebook_converter/ebooks/oeb/polish/__init__.py
+++ b/ebook_converter/ebooks/oeb/polish/__init__.py
@@ -1,10 +0,0 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2013, Kovid Goyal '
-__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/ebook_converter/ebooks/oeb/polish/container.py b/ebook_converter/ebooks/oeb/polish/container.py
index aba74c2..1fc9107 100644
--- a/ebook_converter/ebooks/oeb/polish/container.py
+++ b/ebook_converter/ebooks/oeb/polish/container.py
@@ -19,42 +19,42 @@ from itertools import count
from css_parser import getUrls, replaceUrls
-from calibre import CurrentDir, walk
-from calibre.constants import iswindows
-from calibre.customize.ui import plugin_for_input_format, plugin_for_output_format
-from calibre.ebooks import escape_xpath_attr
-from calibre.ebooks.chardet import xml_to_unicode
-from calibre.ebooks.conversion.plugins.epub_input import (
+from ebook_converter import CurrentDir, walk
+from ebook_converter.constants import iswindows
+from ebook_converter.customize.ui import plugin_for_input_format, plugin_for_output_format
+from ebook_converter.ebooks import escape_xpath_attr
+from ebook_converter.ebooks.chardet import xml_to_unicode
+from ebook_converter.ebooks.conversion.plugins.epub_input import (
ADOBE_OBFUSCATION, IDPF_OBFUSCATION, decrypt_font_data
)
-from calibre.ebooks.conversion.preprocess import (
+from ebook_converter.ebooks.conversion.preprocess import (
CSSPreProcessor as cssp, HTMLPreProcessor
)
-from calibre.ebooks.metadata.opf3 import (
+from ebook_converter.ebooks.metadata.opf3 import (
CALIBRE_PREFIX, ensure_prefix, items_with_property, read_prefixes
)
-from calibre.ebooks.metadata.utils import parse_opf_version
-from calibre.ebooks.mobi import MobiError
-from calibre.ebooks.mobi.reader.headers import MetadataHeader
-from calibre.ebooks.mobi.tweak import set_cover
-from calibre.ebooks.oeb.base import (
+from ebook_converter.ebooks.metadata.utils import parse_opf_version
+from ebook_converter.ebooks.mobi import MobiError
+from ebook_converter.ebooks.mobi.reader.headers import MetadataHeader
+from ebook_converter.ebooks.mobi.tweak import set_cover
+from ebook_converter.ebooks.oeb.base import (
DC11_NS, OEB_DOCS, OEB_STYLES, OPF, OPF2_NS, Manifest, itercsslinks, iterlinks,
rewrite_links, serialize, urlquote, urlunquote
)
-from calibre.ebooks.oeb.parse_utils import NotHTML, parse_html
-from calibre.ebooks.oeb.polish.errors import DRMError, InvalidBook
-from calibre.ebooks.oeb.polish.parsing import parse as parse_html_tweak
-from calibre.ebooks.oeb.polish.utils import (
+from ebook_converter.ebooks.oeb.parse_utils import NotHTML, parse_html
+from ebook_converter.ebooks.oeb.polish.errors import DRMError, InvalidBook
+from ebook_converter.ebooks.oeb.polish.parsing import parse as parse_html_tweak
+from ebook_converter.ebooks.oeb.polish.utils import (
CommentFinder, PositionFinder, guess_type, parse_css
)
-from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile
-from calibre.utils.filenames import hardlink_file, nlinks_file
-from calibre.utils.ipc.simple_worker import WorkerError, fork_job
-from calibre.utils.logging import default_log
-from calibre.utils.xml_parse import safe_xml_fromstring
-from calibre.utils.zipfile import ZipFile
-from polyglot.builtins import iteritems, map, unicode_type, zip
-from polyglot.urllib import urlparse
+from ebook_converter.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile
+from ebook_converter.utils.filenames import hardlink_file, nlinks_file
+from ebook_converter.utils.ipc.simple_worker import WorkerError, fork_job
+from ebook_converter.utils.logging import default_log
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.utils.zipfile import ZipFile
+from ebook_converter.polyglot.builtins import iteritems, map, unicode_type, zip
+from ebook_converter.polyglot.urllib import urlparse
exists, join, relpath = os.path.exists, os.path.join, os.path.relpath
@@ -432,7 +432,7 @@ class Container(ContainerBase): # {{{
if current_name == self.opf_name:
self.opf_name = new_name
if os.path.dirname(old_path) != os.path.dirname(new_path):
- from calibre.ebooks.oeb.polish.replace import LinkRebaser
+ from ebook_converter.ebooks.oeb.polish.replace import LinkRebaser
repl = LinkRebaser(self, current_name, new_name)
self.replace_links(new_name, repl)
self.dirty(new_name)
@@ -641,7 +641,7 @@ class Container(ContainerBase): # {{{
''' The metadata of this book as a Metadata object. Note that this
object is constructed on the fly every time this property is requested,
so use it sparingly. '''
- from calibre.ebooks.metadata.opf2 import OPF as O
+ from ebook_converter.ebooks.metadata.opf2 import OPF as O
mi = self.serialize_item(self.opf_name)
return O(BytesIO(mi), basedir=self.opf_dir, unquote_urls=False,
populate_spine=False).to_book_metadata()
@@ -1158,7 +1158,7 @@ class EpubContainer(Container):
except:
log.exception('EPUB appears to be invalid ZIP file, trying a'
' more forgiving ZIP parser')
- from calibre.utils.localunzip import extractall
+ from ebook_converter.utils.localunzip import extractall
stream.seek(0)
extractall(stream, path=tdir)
try:
@@ -1320,7 +1320,7 @@ class EpubContainer(Container):
self.obfuscated_fonts[font] = (alg, tkey)
def update_modified_timestamp(self):
- from calibre.ebooks.metadata.opf3 import set_last_modified_in_opf
+ from ebook_converter.ebooks.metadata.opf3 import set_last_modified_in_opf
set_last_modified_in_opf(self.opf)
self.dirty(self.opf_name)
@@ -1372,7 +1372,7 @@ class EpubContainer(Container):
shutil.copyfileobj(src, dest)
else:
- from calibre.ebooks.tweak import zip_rebuilder
+ from ebook_converter.ebooks.tweak import zip_rebuilder
with lopen(join(self.root, 'mimetype'), 'wb') as f:
et = guess_type('a.epub')
if not isinstance(et, bytes):
@@ -1401,8 +1401,8 @@ class InvalidMobi(InvalidBook):
def do_explode(path, dest):
- from calibre.ebooks.mobi.reader.mobi6 import MobiReader
- from calibre.ebooks.mobi.reader.mobi8 import Mobi8Reader
+ from ebook_converter.ebooks.mobi.reader.mobi6 import MobiReader
+ from ebook_converter.ebooks.mobi.reader.mobi8 import Mobi8Reader
with lopen(path, 'rb') as stream:
mr = MobiReader(stream, default_log, None, None)
@@ -1415,7 +1415,7 @@ def do_explode(path, dest):
def opf_to_azw3(opf, outpath, container):
- from calibre.ebooks.conversion.plumber import Plumber, create_oebbook
+ from ebook_converter.ebooks.conversion.plumber import Plumber, create_oebbook
class Item(Manifest.Item):
@@ -1489,7 +1489,7 @@ class AZW3Container(Container):
try:
opf_path, obfuscated_fonts = fork_job(
- 'calibre.ebooks.oeb.polish.container', 'do_explode',
+ 'ebook_converter.ebooks.oeb.polish.container', 'do_explode',
args=(pathtoazw3, tdir), no_output=True)['result']
except WorkerError as e:
log(e.orig_tb)
diff --git a/ebook_converter/ebooks/oeb/polish/errors.py b/ebook_converter/ebooks/oeb/polish/errors.py
index d394627..06025ac 100644
--- a/ebook_converter/ebooks/oeb/polish/errors.py
+++ b/ebook_converter/ebooks/oeb/polish/errors.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from calibre.ebooks import DRMError as _DRMError
+from ebook_converter.ebooks import DRMError as _DRMError
class InvalidBook(ValueError):
diff --git a/ebook_converter/ebooks/oeb/polish/opf.py b/ebook_converter/ebooks/oeb/polish/opf.py
index b5aa6df..a70c86e 100644
--- a/ebook_converter/ebooks/oeb/polish/opf.py
+++ b/ebook_converter/ebooks/oeb/polish/opf.py
@@ -7,8 +7,8 @@ __copyright__ = '2014, Kovid Goyal '
from lxml import etree
-from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES
-from calibre.utils.localization import canonicalize_lang
+from ebook_converter.ebooks.oeb.polish.container import OPF_NAMESPACES
+from ebook_converter.utils.localization import canonicalize_lang
def get_book_language(container):
diff --git a/ebook_converter/ebooks/oeb/polish/parsing.py b/ebook_converter/ebooks/oeb/polish/parsing.py
index 2d0ee7d..2be9481 100644
--- a/ebook_converter/ebooks/oeb/polish/parsing.py
+++ b/ebook_converter/ebooks/oeb/polish/parsing.py
@@ -10,11 +10,11 @@ import re
from lxml.etree import Element as LxmlElement
import html5_parser
-from calibre import xml_replace_entities
-from calibre.utils.xml_parse import safe_xml_fromstring
-from calibre.ebooks.chardet import xml_to_unicode, strip_encoding_declarations
-from calibre.utils.cleantext import clean_xml_chars
-from polyglot.builtins import unicode_type
+from ebook_converter import xml_replace_entities
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.ebooks.chardet import xml_to_unicode, strip_encoding_declarations
+from ebook_converter.utils.cleantext import clean_xml_chars
+from ebook_converter.polyglot.builtins import unicode_type
XHTML_NS = 'http://www.w3.org/1999/xhtml'
diff --git a/ebook_converter/ebooks/oeb/polish/pretty.py b/ebook_converter/ebooks/oeb/polish/pretty.py
index e2e55dd..2a4c857 100644
--- a/ebook_converter/ebooks/oeb/polish/pretty.py
+++ b/ebook_converter/ebooks/oeb/polish/pretty.py
@@ -6,16 +6,16 @@ __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
import textwrap
-from polyglot.builtins import iteritems, map
+from ebook_converter.polyglot.builtins import iteritems, map
# from lxml.etree import Element
-from calibre import force_unicode
-from calibre.ebooks.oeb.base import (
+from ebook_converter import force_unicode
+from ebook_converter.ebooks.oeb.base import (
serialize, OEB_DOCS, barename, OEB_STYLES, XPNSMAP, XHTML, SVG)
-from calibre.ebooks.oeb.polish.container import OPF_NAMESPACES
-from calibre.ebooks.oeb.polish.utils import guess_type
-from calibre.utils.icu import sort_key
+from ebook_converter.ebooks.oeb.polish.container import OPF_NAMESPACES
+from ebook_converter.ebooks.oeb.polish.utils import guess_type
+from ebook_converter.utils.icu import sort_key
def isspace(x):
diff --git a/ebook_converter/ebooks/oeb/polish/toc.py b/ebook_converter/ebooks/oeb/polish/toc.py
index 6af462d..d1dd82f 100644
--- a/ebook_converter/ebooks/oeb/polish/toc.py
+++ b/ebook_converter/ebooks/oeb/polish/toc.py
@@ -14,17 +14,17 @@ from operator import itemgetter
from lxml import etree
from lxml.builder import ElementMaker
-from calibre import __version__
-from calibre.ebooks.oeb.base import (
+from ebook_converter import __version__
+from ebook_converter.ebooks.oeb.base import (
XPath, uuid_id, xml2text, NCX, NCX_NS, XML, XHTML, XHTML_NS, serialize, EPUB_NS, XML_NS, OEB_DOCS)
-from calibre.ebooks.oeb.polish.errors import MalformedMarkup
-from calibre.ebooks.oeb.polish.utils import guess_type, extract
-from calibre.ebooks.oeb.polish.opf import set_guide_item, get_book_language
-from calibre.ebooks.oeb.polish.pretty import pretty_html_tree
-from calibre.translations.dynamic import translate
-from calibre.utils.localization import get_lang, canonicalize_lang, lang_as_iso639_1
-from polyglot.builtins import iteritems, map, unicode_type
-from polyglot.urllib import urlparse
+from ebook_converter.ebooks.oeb.polish.errors import MalformedMarkup
+from ebook_converter.ebooks.oeb.polish.utils import guess_type, extract
+from ebook_converter.ebooks.oeb.polish.opf import set_guide_item, get_book_language
+from ebook_converter.ebooks.oeb.polish.pretty import pretty_html_tree
+from ebook_converter.translations.dynamic import translate
+from ebook_converter.utils.localization import get_lang, canonicalize_lang, lang_as_iso639_1
+from ebook_converter.polyglot.builtins import iteritems, map, unicode_type
+from ebook_converter.polyglot.urllib import urlparse
ns = etree.FunctionNamespace('calibre_xpath_extensions')
ns.prefix = 'calibre'
@@ -677,7 +677,7 @@ def ensure_single_nav_of_type(root, ntype='toc'):
def commit_nav_toc(container, toc, lang=None, landmarks=None, previous_nav=None):
- from calibre.ebooks.oeb.polish.pretty import pretty_xml_tree
+ from ebook_converter.ebooks.oeb.polish.pretty import pretty_xml_tree
tocname = find_existing_nav_toc(container)
if previous_nav is not None:
nav_name = container.href_to_name(previous_nav[0])
diff --git a/ebook_converter/ebooks/oeb/polish/utils.py b/ebook_converter/ebooks/oeb/polish/utils.py
index b502578..c68186c 100644
--- a/ebook_converter/ebooks/oeb/polish/utils.py
+++ b/ebook_converter/ebooks/oeb/polish/utils.py
@@ -8,8 +8,8 @@ __copyright__ = '2013, Kovid Goyal '
import re, os
from bisect import bisect
-from calibre import guess_type as _guess_type, replace_entities
-from polyglot.builtins import filter
+from ebook_converter import guess_type as _guess_type, replace_entities
+from ebook_converter.polyglot.builtins import filter
def guess_type(x):
@@ -25,7 +25,7 @@ def setup_css_parser_serialization(tab_width=2):
def actual_case_for_name(container, name):
- from calibre.utils.filenames import samefile
+ from ebook_converter.utils.filenames import samefile
if not container.exists(name):
raise ValueError('Cannot get actual case for %s as it does not exist' % name)
parts = name.split('/')
@@ -103,7 +103,7 @@ class CommentFinder(object):
def link_stylesheets(container, names, sheets, remove=False, mtype='text/css'):
- from calibre.ebooks.oeb.base import XPath, XHTML
+ from ebook_converter.ebooks.oeb.base import XPath, XHTML
changed_names = set()
snames = set(sheets)
lp = XPath('//h:link[@href]')
@@ -164,7 +164,7 @@ def parse_css(data, fname='', is_declaration=False, decode=None, log_lev
import logging
log_level = logging.WARNING
from css_parser import CSSParser, log
- from calibre.ebooks.oeb.base import _css_logger
+ from ebook_converter.ebooks.oeb.base import _css_logger
log.setLevel(log_level)
log.raiseExceptions = False
data = data or ''
diff --git a/ebook_converter/ebooks/oeb/reader.py b/ebook_converter/ebooks/oeb/reader.py
index 2c248a8..527ed9c 100644
--- a/ebook_converter/ebooks/oeb/reader.py
+++ b/ebook_converter/ebooks/oeb/reader.py
@@ -11,24 +11,24 @@ from collections import defaultdict
from lxml import etree
-from calibre.ebooks.oeb.base import OPF1_NS, OPF2_NS, OPF2_NSMAP, DC11_NS, \
+from ebook_converter.ebooks.oeb.base import OPF1_NS, OPF2_NS, OPF2_NSMAP, DC11_NS, \
DC_NSES, OPF, xml2text, XHTML_MIME
-from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, OEB_IMAGES, \
+from ebook_converter.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, OEB_IMAGES, \
PAGE_MAP_MIME, JPEG_MIME, NCX_MIME, SVG_MIME
-from calibre.ebooks.oeb.base import XMLDECL_RE, COLLAPSE_RE, \
+from ebook_converter.ebooks.oeb.base import XMLDECL_RE, COLLAPSE_RE, \
MS_COVER_TYPE, iterlinks
-from calibre.ebooks.oeb.base import namespace, barename, XPath, xpath, \
+from ebook_converter.ebooks.oeb.base import namespace, barename, XPath, xpath, \
urlnormalize, BINARY_MIME, \
OEBError, OEBBook, DirContainer
-from calibre.ebooks.oeb.writer import OEBWriter
-from calibre.utils.xml_parse import safe_xml_fromstring
-from calibre.utils.cleantext import clean_xml_chars
-from calibre.utils.localization import get_lang
-from calibre.ptempfile import TemporaryDirectory
-from calibre.constants import __appname__, __version__
-from calibre import guess_type, xml_replace_entities
-from polyglot.builtins import unicode_type, zip
-from polyglot.urllib import unquote, urldefrag, urlparse
+from ebook_converter.ebooks.oeb.writer import OEBWriter
+from ebook_converter.utils.xml_parse import safe_xml_fromstring
+from ebook_converter.utils.cleantext import clean_xml_chars
+from ebook_converter.utils.localization import get_lang
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.constants import __appname__, __version__
+from ebook_converter import guess_type, xml_replace_entities
+from ebook_converter.polyglot.builtins import unicode_type, zip
+from ebook_converter.polyglot.urllib import unquote, urldefrag, urlparse
__all__ = ['OEBReader']
@@ -129,8 +129,8 @@ class OEBReader(object):
return opf
def _metadata_from_opf(self, opf):
- from calibre.ebooks.metadata.opf2 import OPF
- from calibre.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
+ from ebook_converter.ebooks.metadata.opf2 import OPF
+ from ebook_converter.ebooks.oeb.transforms.metadata import meta_info_to_oeb_metadata
stream = io.BytesIO(etree.tostring(opf, xml_declaration=True, encoding='utf-8'))
o = OPF(stream)
pwm = o.primary_writing_mode
@@ -621,7 +621,7 @@ class OEBReader(object):
return
def _cover_from_html(self, hcover):
- from calibre.ebooks import render_html_svg_workaround
+ from ebook_converter.ebooks import render_html_svg_workaround
with TemporaryDirectory('_html_cover') as tdir:
writer = OEBWriter()
writer(self.oeb, tdir)
diff --git a/ebook_converter/ebooks/oeb/stylizer.py b/ebook_converter/ebooks/oeb/stylizer.py
index 109cccd..26cb61c 100644
--- a/ebook_converter/ebooks/oeb/stylizer.py
+++ b/ebook_converter/ebooks/oeb/stylizer.py
@@ -16,13 +16,13 @@ from css_parser.css import (CSSStyleRule, CSSPageRule, CSSFontFaceRule,
cssproperties)
from css_parser import (profile as cssprofiles, parseString, parseStyle, log as
css_parser_log, CSSParser, profiles, replaceUrls)
-from calibre import force_unicode, as_unicode
-from calibre.ebooks import unit_convert
-from calibre.ebooks.oeb.base import XHTML, XHTML_NS, CSS_MIME, OEB_STYLES, xpath, urlnormalize
-from calibre.ebooks.oeb.normalize_css import DEFAULTS, normalizers
-from css_selectors import Select, SelectorError, INAPPROPRIATE_PSEUDO_CLASSES
-from polyglot.builtins import iteritems, unicode_type, filter
-from tinycss.media3 import CSSMedia3Parser
+from ebook_converter import force_unicode, as_unicode
+from ebook_converter.ebooks import unit_convert
+from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, CSS_MIME, OEB_STYLES, xpath, urlnormalize
+from ebook_converter.ebooks.oeb.normalize_css import DEFAULTS, normalizers
+from ebook_converter.css_selectors import Select, SelectorError, INAPPROPRIATE_PSEUDO_CLASSES
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, filter
+from ebook_converter.tinycss.media3 import CSSMedia3Parser
css_parser_log.setLevel(logging.WARN)
@@ -194,7 +194,7 @@ class Stylizer(object):
# Use the default profile. This should really be using
# opts.output_profile, but I don't want to risk changing it, as
# doing so might well have hard to debug font size effects.
- from calibre.customize.ui import output_profiles
+ from ebook_converter.customize.ui import output_profiles
for x in output_profiles():
if x.short_name == 'default':
self.profile = x
diff --git a/ebook_converter/ebooks/oeb/transforms/__init__.py b/ebook_converter/ebooks/oeb/transforms/__init__.py
index 720ff71..e69de29 100644
--- a/ebook_converter/ebooks/oeb/transforms/__init__.py
+++ b/ebook_converter/ebooks/oeb/transforms/__init__.py
@@ -1,7 +0,0 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2009, Kovid Goyal '
-__docformat__ = 'restructuredtext en'
diff --git a/ebook_converter/ebooks/oeb/transforms/data_url.py b/ebook_converter/ebooks/oeb/transforms/data_url.py
index 829354c..b45295b 100644
--- a/ebook_converter/ebooks/oeb/transforms/data_url.py
+++ b/ebook_converter/ebooks/oeb/transforms/data_url.py
@@ -6,14 +6,14 @@ __license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal '
import re
-from calibre.ebooks.oeb.base import XPath, urlunquote
-from polyglot.builtins import as_bytes
+from ebook_converter.ebooks.oeb.base import XPath, urlunquote
+from ebook_converter.polyglot.builtins import as_bytes
class DataURL(object):
def __call__(self, oeb, opts):
- from calibre.utils.imghdr import what
+ from ebook_converter.utils.imghdr import what
self.log = oeb.log
attr_path = XPath('//h:img[@src]')
for item in oeb.spine:
@@ -29,7 +29,7 @@ class DataURL(object):
continue
if ';base64' in header:
data = re.sub(r'\s+', '', data)
- from polyglot.binary import from_base64_bytes
+ from ebook_converter.polyglot.binary import from_base64_bytes
try:
data = from_base64_bytes(data)
except Exception:
@@ -46,7 +46,7 @@ class DataURL(object):
def convert_image_data_uri(self, data, fmt, oeb):
self.log('Found image encoded as data URI converting it to normal image')
- from calibre import guess_type
+ from ebook_converter import guess_type
item_id, item_href = oeb.manifest.generate('data-url-image', 'data-url-image.' + fmt)
oeb.manifest.add(item_id, item_href, guess_type(item_href)[0], data=data)
return item_href
diff --git a/ebook_converter/ebooks/oeb/transforms/flatcss.py b/ebook_converter/ebooks/oeb/transforms/flatcss.py
index 43c2b19..2b4a764 100644
--- a/ebook_converter/ebooks/oeb/transforms/flatcss.py
+++ b/ebook_converter/ebooks/oeb/transforms/flatcss.py
@@ -14,14 +14,14 @@ from lxml import etree
import css_parser
from css_parser.css import Property
-from calibre import guess_type
-from calibre.ebooks import unit_convert
-from calibre.ebooks.oeb.base import (XHTML, XHTML_NS, CSS_MIME, OEB_STYLES,
+from ebook_converter import guess_type
+from ebook_converter.ebooks import unit_convert
+from ebook_converter.ebooks.oeb.base import (XHTML, XHTML_NS, CSS_MIME, OEB_STYLES,
namespace, barename, XPath, css_text)
-from calibre.ebooks.oeb.stylizer import Stylizer
-from calibre.utils.filenames import ascii_filename, ascii_text
-from calibre.utils.icu import numeric_sort_key
-from polyglot.builtins import iteritems, unicode_type, string_or_bytes, map
+from ebook_converter.ebooks.oeb.stylizer import Stylizer
+from ebook_converter.utils.filenames import ascii_filename, ascii_text
+from ebook_converter.utils.icu import numeric_sort_key
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, map
COLLAPSE = re.compile(r'[ \t\r\n\v]+')
STRIPNUM = re.compile(r'[-0-9]+$')
@@ -139,7 +139,7 @@ class CSSFlattener(object):
self.fbase = fbase
self.transform_css_rules = transform_css_rules
if self.transform_css_rules:
- from calibre.ebooks.css_transform_rules import compile_rules
+ from ebook_converter.ebooks.css_transform_rules import compile_rules
self.transform_css_rules = compile_rules(self.transform_css_rules)
self.fkey = fkey
self.lineh = lineh
@@ -180,7 +180,7 @@ class CSSFlattener(object):
except:
self.oeb.log.warning('Failed to parse filter_css, ignoring')
else:
- from calibre.ebooks.oeb.normalize_css import normalize_filter_css
+ from ebook_converter.ebooks.oeb.normalize_css import normalize_filter_css
self.filter_css = frozenset(normalize_filter_css(self.filter_css))
self.oeb.log.debug('Filtering CSS properties: %s'%
', '.join(self.filter_css))
@@ -223,8 +223,8 @@ class CSSFlattener(object):
body_font_family = None
if not family:
return body_font_family, efi
- from calibre.utils.fonts.scanner import font_scanner, NoFonts
- from calibre.utils.fonts.utils import panose_to_css_generic_family
+ from ebook_converter.utils.fonts.scanner import font_scanner, NoFonts
+ from ebook_converter.utils.fonts.utils import panose_to_css_generic_family
try:
faces = font_scanner.fonts_for_family(family)
except NoFonts:
@@ -610,7 +610,7 @@ class CSSFlattener(object):
id, href = manifest.generate('css', 'stylesheet.css')
sheet = css_parser.parseString(css, validate=False)
if self.transform_css_rules:
- from calibre.ebooks.css_transform_rules import transform_sheet
+ from ebook_converter.ebooks.css_transform_rules import transform_sheet
transform_sheet(self.transform_css_rules, sheet)
item = manifest.add(id, href, CSS_MIME, data=sheet)
self.oeb.manifest.main_stylesheet = item
@@ -642,7 +642,7 @@ class CSSFlattener(object):
id_, href = manifest.generate('page_css', 'page_styles.css')
sheet = css_parser.parseString(css, validate=False)
if self.transform_css_rules:
- from calibre.ebooks.css_transform_rules import transform_sheet
+ from ebook_converter.ebooks.css_transform_rules import transform_sheet
transform_sheet(self.transform_css_rules, sheet)
manifest.add(id_, href, CSS_MIME, data=sheet)
gc_map[css] = href
@@ -664,7 +664,7 @@ class CSSFlattener(object):
fsize = self.context.dest.fbase
self.flatten_node(html, stylizer, names, styles, pseudo_styles, fsize, item.id, recurse=False)
self.flatten_node(html.find(XHTML('body')), stylizer, names, styles, pseudo_styles, fsize, item.id)
- items = sorted(((key, val) for (val, key) in iteritems(styles)), key=lambda x:numeric_sort_key(x[0]))
+ items = sorted(((key, val) for (val, key) in iteritems(styles)))
# :hover must come after link and :active must come after :hover
psels = sorted(pseudo_styles, key=lambda x :
{'hover':1, 'active':2}.get(x, 0))
diff --git a/ebook_converter/ebooks/oeb/transforms/jacket.py b/ebook_converter/ebooks/oeb/transforms/jacket.py
index 24f1aa9..dd3002c 100644
--- a/ebook_converter/ebooks/oeb/transforms/jacket.py
+++ b/ebook_converter/ebooks/oeb/transforms/jacket.py
@@ -10,15 +10,15 @@ import sys, os, re
from xml.sax.saxutils import escape
from string import Formatter
-from calibre import guess_type, strftime
-from calibre.constants import iswindows
-from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag, urlnormalize
-from calibre.library.comments import comments_to_html, markdown
-from calibre.utils.date import is_date_undefined, as_local_time
-from calibre.utils.icu import sort_key
-from calibre.ebooks.chardet import strip_encoding_declarations
-from calibre.ebooks.metadata import fmt_sidx, rating_to_stars
-from polyglot.builtins import unicode_type, map
+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
JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]'
@@ -346,7 +346,7 @@ def render_jacket(mi, output_profile,
return strip_encoding_declarations(generated_html)
- from calibre.ebooks.oeb.polish.parsing import parse
+ from ebook_converter.ebooks.oeb.polish.parsing import parse
raw = generate_html(comments)
root = parse(raw, line_numbers=False, force_html5_parse=True)
@@ -367,7 +367,7 @@ def render_jacket(mi, output_profile,
fw.append(child)
body.append(fw)
postprocess_jacket(root, output_profile, has_data)
- from calibre.ebooks.oeb.polish.pretty import pretty_html_tree
+ from ebook_converter.ebooks.oeb.polish.pretty import pretty_html_tree
pretty_html_tree(None, root)
return root
diff --git a/ebook_converter/ebooks/oeb/transforms/metadata.py b/ebook_converter/ebooks/oeb/transforms/metadata.py
index 71c3a7e..097cc6d 100644
--- a/ebook_converter/ebooks/oeb/transforms/metadata.py
+++ b/ebook_converter/ebooks/oeb/transforms/metadata.py
@@ -7,13 +7,13 @@ __copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
import os, re
-from calibre.utils.date import isoformat, now
-from calibre import guess_type
-from polyglot.builtins import iteritems
+from ebook_converter.utils.date import isoformat, now
+from ebook_converter import guess_type
+from ebook_converter.polyglot.builtins import iteritems
def meta_info_to_oeb_metadata(mi, m, log, override_input_metadata=False):
- from calibre.ebooks.oeb.base import OPF
+ from ebook_converter.ebooks.oeb.base import OPF
if not mi.is_null('title'):
m.clear('title')
m.add('title', mi.title)
@@ -167,7 +167,7 @@ class MergeMetadata(object):
return id
def remove_old_cover(self, cover_item, new_cover_href=None):
- from calibre.ebooks.oeb.base import XPath, XLINK
+ from ebook_converter.ebooks.oeb.base import XPath, XLINK
from lxml import etree
self.oeb.manifest.remove(cover_item)
diff --git a/ebook_converter/ebooks/oeb/transforms/page_margin.py b/ebook_converter/ebooks/oeb/transforms/page_margin.py
index 6f42afc..decf9f3 100644
--- a/ebook_converter/ebooks/oeb/transforms/page_margin.py
+++ b/ebook_converter/ebooks/oeb/transforms/page_margin.py
@@ -9,8 +9,8 @@ __docformat__ = 'restructuredtext en'
import numbers
from collections import Counter
-from calibre.ebooks.oeb.base import barename, XPath
-from polyglot.builtins import iteritems
+from ebook_converter.ebooks.oeb.base import barename, XPath
+from ebook_converter.polyglot.builtins import iteritems
class RemoveAdobeMargins(object):
diff --git a/ebook_converter/ebooks/oeb/transforms/structure.py b/ebook_converter/ebooks/oeb/transforms/structure.py
index cd5211c..a16b70d 100644
--- a/ebook_converter/ebooks/oeb/transforms/structure.py
+++ b/ebook_converter/ebooks/oeb/transforms/structure.py
@@ -11,10 +11,10 @@ import re, uuid
from lxml import etree
from collections import OrderedDict, Counter
-from calibre.ebooks.oeb.base import XPNSMAP, TOC, XHTML, xml2text, barename
-from calibre.ebooks import ConversionError
-from polyglot.builtins import itervalues, unicode_type
-from polyglot.urllib import urlparse
+from ebook_converter.ebooks.oeb.base import XPNSMAP, TOC, XHTML, xml2text, barename
+from ebook_converter.ebooks import ConversionError
+from ebook_converter.polyglot.builtins import itervalues, unicode_type
+from ebook_converter.polyglot.urllib import urlparse
def XPath(x):
diff --git a/ebook_converter/ebooks/oeb/transforms/trimmanifest.py b/ebook_converter/ebooks/oeb/transforms/trimmanifest.py
index d67f0e4..900fdf1 100644
--- a/ebook_converter/ebooks/oeb/transforms/trimmanifest.py
+++ b/ebook_converter/ebooks/oeb/transforms/trimmanifest.py
@@ -6,9 +6,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift '
-from calibre.ebooks.oeb.base import CSS_MIME, OEB_DOCS
-from calibre.ebooks.oeb.base import urlnormalize, iterlinks
-from polyglot.urllib import urldefrag
+from ebook_converter.ebooks.oeb.base import CSS_MIME, OEB_DOCS
+from ebook_converter.ebooks.oeb.base import urlnormalize, iterlinks
+from ebook_converter.polyglot.urllib import urldefrag
class ManifestTrimmer(object):
diff --git a/ebook_converter/ebooks/oeb/writer.py b/ebook_converter/ebooks/oeb/writer.py
index 953c492..f6e01f8 100644
--- a/ebook_converter/ebooks/oeb/writer.py
+++ b/ebook_converter/ebooks/oeb/writer.py
@@ -7,8 +7,8 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift '
import os
-from calibre.ebooks.oeb.base import OPF_MIME, xml2str
-from calibre.ebooks.oeb.base import DirContainer, OEBError
+from ebook_converter.ebooks.oeb.base import OPF_MIME, xml2str
+from ebook_converter.ebooks.oeb.base import DirContainer, OEBError
__all__ = ['OEBWriter']
diff --git a/ebook_converter/ebooks/pdb/__init__.py b/ebook_converter/ebooks/pdb/__init__.py
index 599744f..870dc34 100644
--- a/ebook_converter/ebooks/pdb/__init__.py
+++ b/ebook_converter/ebooks/pdb/__init__.py
@@ -15,12 +15,12 @@ FORMAT_READERS = None
def _import_readers():
global FORMAT_READERS
- from calibre.ebooks.pdb.ereader.reader import Reader as ereader_reader
- from calibre.ebooks.pdb.palmdoc.reader import Reader as palmdoc_reader
- from calibre.ebooks.pdb.ztxt.reader import Reader as ztxt_reader
- from calibre.ebooks.pdb.pdf.reader import Reader as pdf_reader
- from calibre.ebooks.pdb.plucker.reader import Reader as plucker_reader
- from calibre.ebooks.pdb.haodoo.reader import Reader as haodoo_reader
+ from ebook_converter.ebooks.pdb.ereader.reader import Reader as ereader_reader
+ from ebook_converter.ebooks.pdb.palmdoc.reader import Reader as palmdoc_reader
+ from ebook_converter.ebooks.pdb.ztxt.reader import Reader as ztxt_reader
+ from ebook_converter.ebooks.pdb.pdf.reader import Reader as pdf_reader
+ from ebook_converter.ebooks.pdb.plucker.reader import Reader as plucker_reader
+ from ebook_converter.ebooks.pdb.haodoo.reader import Reader as haodoo_reader
FORMAT_READERS = {
'PNPdPPrs': ereader_reader,
@@ -40,9 +40,9 @@ FORMAT_WRITERS = None
def _import_writers():
global FORMAT_WRITERS
- from calibre.ebooks.pdb.palmdoc.writer import Writer as palmdoc_writer
- from calibre.ebooks.pdb.ztxt.writer import Writer as ztxt_writer
- from calibre.ebooks.pdb.ereader.writer import Writer as ereader_writer
+ from ebook_converter.ebooks.pdb.palmdoc.writer import Writer as palmdoc_writer
+ from ebook_converter.ebooks.pdb.ztxt.writer import Writer as ztxt_writer
+ from ebook_converter.ebooks.pdb.ereader.writer import Writer as ereader_writer
FORMAT_WRITERS = {
'doc': palmdoc_writer,
diff --git a/ebook_converter/ebooks/pdb/ereader/reader.py b/ebook_converter/ebooks/pdb/ereader/reader.py
index bd2bb97..48745b3 100644
--- a/ebook_converter/ebooks/pdb/ereader/reader.py
+++ b/ebook_converter/ebooks/pdb/ereader/reader.py
@@ -9,10 +9,10 @@ __license__ = 'GPL v3'
__copyright__ = '2009, John Schember '
__docformat__ = 'restructuredtext en'
-from calibre.ebooks.pdb.ereader import EreaderError
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ebooks.pdb.ereader.reader132 import Reader132
-from calibre.ebooks.pdb.ereader.reader202 import Reader202
+from ebook_converter.ebooks.pdb.ereader import EreaderError
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.pdb.ereader.reader132 import Reader132
+from ebook_converter.ebooks.pdb.ereader.reader202 import Reader202
class Reader(FormatReader):
diff --git a/ebook_converter/ebooks/pdb/ereader/reader132.py b/ebook_converter/ebooks/pdb/ereader/reader132.py
index b98c5e8..2881e15 100644
--- a/ebook_converter/ebooks/pdb/ereader/reader132.py
+++ b/ebook_converter/ebooks/pdb/ereader/reader132.py
@@ -14,12 +14,12 @@ import re
import struct
import zlib
-from calibre import CurrentDir
-from calibre.ebooks import DRMError
-from calibre.ebooks.metadata.opf2 import OPFCreator
-from calibre.ebooks.pdb.ereader import EreaderError
-from calibre.ebooks.pdb.formatreader import FormatReader
-from polyglot.builtins import unicode_type, range
+from ebook_converter import CurrentDir
+from ebook_converter.ebooks import DRMError
+from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+from ebook_converter.ebooks.pdb.ereader import EreaderError
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.polyglot.builtins import unicode_type, range
class HeaderRecord(object):
@@ -73,7 +73,7 @@ class Reader132(FormatReader):
else:
raise EreaderError('Unknown book compression %i.' % self.header_record.compression)
- from calibre.ebooks.metadata.pdb import get_metadata
+ from ebook_converter.ebooks.metadata.pdb import get_metadata
self.mi = get_metadata(stream, False)
def section_data(self, number):
@@ -81,7 +81,7 @@ class Reader132(FormatReader):
def decompress_text(self, number):
if self.header_record.compression == 2:
- from calibre.ebooks.compression.palmdoc import decompress_doc
+ from ebook_converter.ebooks.compression.palmdoc import decompress_doc
return decompress_doc(self.section_data(number)).decode('cp1252' if self.encoding is None else self.encoding, 'replace')
if self.header_record.compression == 10:
return zlib.decompress(self.section_data(number)).decode('cp1252' if self.encoding is None else self.encoding, 'replace')
@@ -106,8 +106,8 @@ class Reader132(FormatReader):
return self.decompress_text(number)
def extract_content(self, output_dir):
- from calibre.ebooks.pml.pmlconverter import footnote_to_html, sidebar_to_html
- from calibre.ebooks.pml.pmlconverter import PML_HTMLizer
+ from ebook_converter.ebooks.pml.pmlconverter import footnote_to_html, sidebar_to_html
+ from ebook_converter.ebooks.pml.pmlconverter import PML_HTMLizer
output_dir = os.path.abspath(output_dir)
diff --git a/ebook_converter/ebooks/pdb/ereader/reader202.py b/ebook_converter/ebooks/pdb/ereader/reader202.py
index fd69b19..7695b41 100644
--- a/ebook_converter/ebooks/pdb/ereader/reader202.py
+++ b/ebook_converter/ebooks/pdb/ereader/reader202.py
@@ -12,11 +12,11 @@ __docformat__ = 'restructuredtext en'
import os
import struct
-from calibre import CurrentDir
-from calibre.ebooks.metadata.opf2 import OPFCreator
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ebooks.pdb.ereader import EreaderError
-from polyglot.builtins import unicode_type, range
+from ebook_converter import CurrentDir
+from ebook_converter.ebooks.metadata.opf2 import OPFCreator
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.pdb.ereader import EreaderError
+from ebook_converter.polyglot.builtins import unicode_type, range
class HeaderRecord(object):
@@ -51,14 +51,14 @@ class Reader202(FormatReader):
if self.header_record.version not in (2, 4):
raise EreaderError('Unknown book version %i.' % self.header_record.version)
- from calibre.ebooks.metadata.pdb import get_metadata
+ from ebook_converter.ebooks.metadata.pdb import get_metadata
self.mi = get_metadata(stream, False)
def section_data(self, number):
return self.sections[number]
def decompress_text(self, number):
- from calibre.ebooks.compression.palmdoc import decompress_doc
+ from ebook_converter.ebooks.compression.palmdoc import decompress_doc
data = bytearray(self.section_data(number))
data = bytes(bytearray(x ^ 0xA5 for x in data))
return decompress_doc(data).decode(self.encoding or 'cp1252', 'replace')
@@ -86,7 +86,7 @@ class Reader202(FormatReader):
return self.decompress_text(number)
def extract_content(self, output_dir):
- from calibre.ebooks.pml.pmlconverter import pml_to_html
+ from ebook_converter.ebooks.pml.pmlconverter import pml_to_html
output_dir = os.path.abspath(output_dir)
diff --git a/ebook_converter/ebooks/pdb/haodoo/reader.py b/ebook_converter/ebooks/pdb/haodoo/reader.py
index dc4497f..59d7ece 100644
--- a/ebook_converter/ebooks/pdb/haodoo/reader.py
+++ b/ebook_converter/ebooks/pdb/haodoo/reader.py
@@ -13,11 +13,11 @@ __docformat__ = 'restructuredtext en'
import struct
import os
-from calibre import prepare_string_for_xml
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ebooks.metadata import MetaInformation
-from calibre.ebooks.txt.processor import opf_writer, HTML_TEMPLATE
-from polyglot.builtins import range, map
+from ebook_converter import prepare_string_for_xml
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.metadata import MetaInformation
+from ebook_converter.ebooks.txt.processor import opf_writer, HTML_TEMPLATE
+from ebook_converter.polyglot.builtins import range, map
BPDB_IDENT = b'BOOKMTIT'
UPDB_IDENT = b'BOOKMTIU'
diff --git a/ebook_converter/ebooks/pdb/header.py b/ebook_converter/ebooks/pdb/header.py
index afe7fda..a3995e7 100644
--- a/ebook_converter/ebooks/pdb/header.py
+++ b/ebook_converter/ebooks/pdb/header.py
@@ -13,7 +13,7 @@ __docformat__ = 'restructuredtext en'
import re
import struct
import time
-from polyglot.builtins import long_type
+from ebook_converter.polyglot.builtins import long_type
class PdbHeaderReader(object):
diff --git a/ebook_converter/ebooks/pdb/palmdoc/reader.py b/ebook_converter/ebooks/pdb/palmdoc/reader.py
index 8f84dc7..80c1259 100644
--- a/ebook_converter/ebooks/pdb/palmdoc/reader.py
+++ b/ebook_converter/ebooks/pdb/palmdoc/reader.py
@@ -12,7 +12,7 @@ __docformat__ = 'restructuredtext en'
import struct, io
-from calibre.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
class HeaderRecord(object):
@@ -48,7 +48,7 @@ class Reader(FormatReader):
if self.header_record.compression == 1:
return self.section_data(number)
if self.header_record.compression == 2 or self.header_record.compression == 258:
- from calibre.ebooks.compression.palmdoc import decompress_doc
+ from ebook_converter.ebooks.compression.palmdoc import decompress_doc
return decompress_doc(self.section_data(number))
return b''
@@ -63,7 +63,7 @@ class Reader(FormatReader):
self.log.info('Converting text to OEB...')
stream = io.BytesIO(raw_txt)
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for opt in txt_plugin.options:
diff --git a/ebook_converter/ebooks/pdb/pdf/reader.py b/ebook_converter/ebooks/pdb/pdf/reader.py
index df0af2c..df688c0 100644
--- a/ebook_converter/ebooks/pdb/pdf/reader.py
+++ b/ebook_converter/ebooks/pdb/pdf/reader.py
@@ -10,9 +10,9 @@ __copyright__ = '2010, John Schember '
__docformat__ = 'restructuredtext en'
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ptempfile import PersistentTemporaryFile
-from polyglot.builtins import range
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ptempfile import PersistentTemporaryFile
+from ebook_converter.polyglot.builtins import range
class Reader(FormatReader):
@@ -33,7 +33,7 @@ class Reader(FormatReader):
pdf.write(self.header.section_data(x))
pdf.close()
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
pdf_plugin = plugin_for_input_format('pdf')
for opt in pdf_plugin.options:
diff --git a/ebook_converter/ebooks/pdb/plucker/reader.py b/ebook_converter/ebooks/pdb/plucker/reader.py
index 76555dc..0be3697 100644
--- a/ebook_converter/ebooks/pdb/plucker/reader.py
+++ b/ebook_converter/ebooks/pdb/plucker/reader.py
@@ -12,12 +12,12 @@ import zlib
from collections import OrderedDict
-from calibre import CurrentDir
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ebooks.compression.palmdoc import decompress_doc
-from calibre.utils.imghdr import identify
-from calibre.utils.img import save_cover_data_to, Canvas, image_from_data
-from polyglot.builtins import codepoint_to_chr, range
+from ebook_converter import CurrentDir
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.compression.palmdoc import decompress_doc
+from ebook_converter.utils.imghdr import identify
+from ebook_converter.utils.img import save_cover_data_to, Canvas, image_from_data
+from ebook_converter.polyglot.builtins import codepoint_to_chr, range
DATATYPE_PHTML = 0
DATATYPE_PHTML_COMPRESSED = 1
@@ -353,7 +353,7 @@ class Reader(FormatReader):
self.owner_id = mdata_section.owner_id
# Get the metadata (tile, author, ...) with the metadata reader.
- from calibre.ebooks.metadata.pdb import get_metadata
+ from ebook_converter.ebooks.metadata.pdb import get_metadata
self.mi = get_metadata(stream, False)
def extract_content(self, output_dir):
@@ -445,7 +445,7 @@ class Reader(FormatReader):
self.log.error('Failed to write composite image with uid %s: %s' % (uid, e))
# Run the HTML through the html processing plugin.
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
html_input = plugin_for_input_format('html')
for opt in html_input.options:
setattr(self.options, opt.option.name, opt.recommended_value)
@@ -474,7 +474,7 @@ class Reader(FormatReader):
raise NotImplementedError
return zlib.decompress(data)
elif self.header_record.compression == 1:
- from calibre.ebooks.compression.palmdoc import decompress_doc
+ from ebook_converter.ebooks.compression.palmdoc import decompress_doc
return decompress_doc(data)
def process_phtml(self, d, paragraph_offsets=[]):
diff --git a/ebook_converter/ebooks/pdb/ztxt/reader.py b/ebook_converter/ebooks/pdb/ztxt/reader.py
index a1c36cf..0b96bbd 100644
--- a/ebook_converter/ebooks/pdb/ztxt/reader.py
+++ b/ebook_converter/ebooks/pdb/ztxt/reader.py
@@ -14,8 +14,8 @@ import zlib
import io
-from calibre.ebooks.pdb.formatreader import FormatReader
-from calibre.ebooks.pdb.ztxt import zTXTError
+from ebook_converter.ebooks.pdb.formatreader import FormatReader
+from ebook_converter.ebooks.pdb.ztxt import zTXTError
SUPPORTED_VERSION = (1, 40)
@@ -83,7 +83,7 @@ class Reader(FormatReader):
self.log.info('Converting text to OEB...')
stream = io.BytesIO(raw_txt)
- from calibre.customize.ui import plugin_for_input_format
+ from ebook_converter.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for opt in txt_plugin.options:
diff --git a/ebook_converter/ebooks/rtf/__init__.py b/ebook_converter/ebooks/rtf/__init__.py
index 8b13789..e69de29 100644
--- a/ebook_converter/ebooks/rtf/__init__.py
+++ b/ebook_converter/ebooks/rtf/__init__.py
@@ -1 +0,0 @@
-
diff --git a/ebook_converter/ebooks/rtf2xml/ParseRtf.py b/ebook_converter/ebooks/rtf2xml/ParseRtf.py
index 164e706..b88ed5e 100644
--- a/ebook_converter/ebooks/rtf2xml/ParseRtf.py
+++ b/ebook_converter/ebooks/rtf2xml/ParseRtf.py
@@ -15,7 +15,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
# $Date: 2006/03/24 23:50:07 $
import sys, os
-from calibre.ebooks.rtf2xml import headings_to_sections, \
+from ebook_converter.ebooks.rtf2xml import headings_to_sections, \
line_endings, footnote, fields_small, default_encoding, \
make_lists, preamble_div, header, colors, group_borders, \
check_encoding, add_brackets, table, combine_borders, \
@@ -25,8 +25,8 @@ from calibre.ebooks.rtf2xml import headings_to_sections, \
list_numbers, info, pict, table_info, fonts, paragraphs, \
body_styles, preamble_rest, group_styles, \
inline
-from calibre.ebooks.rtf2xml.old_rtf import OldRtf
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml.old_rtf import OldRtf
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/add_brackets.py b/ebook_converter/ebooks/rtf2xml/add_brackets.py
index 3f991d5..8bf7aea 100644
--- a/ebook_converter/ebooks/rtf2xml/add_brackets.py
+++ b/ebook_converter/ebooks/rtf2xml/add_brackets.py
@@ -14,9 +14,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy, check_brackets
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import iteritems
+from ebook_converter.ebooks.rtf2xml import copy, check_brackets
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import iteritems
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/body_styles.py b/ebook_converter/ebooks/rtf2xml/body_styles.py
index ec78443..2d1ccc8 100644
--- a/ebook_converter/ebooks/rtf2xml/body_styles.py
+++ b/ebook_converter/ebooks/rtf2xml/body_styles.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
"""
diff --git a/ebook_converter/ebooks/rtf2xml/check_encoding.py b/ebook_converter/ebooks/rtf2xml/check_encoding.py
index c98a4cf..b73bcad 100644
--- a/ebook_converter/ebooks/rtf2xml/check_encoding.py
+++ b/ebook_converter/ebooks/rtf2xml/check_encoding.py
@@ -3,7 +3,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import sys
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
class CheckEncoding:
diff --git a/ebook_converter/ebooks/rtf2xml/colors.py b/ebook_converter/ebooks/rtf2xml/colors.py
index 7530e7b..7bfd500 100644
--- a/ebook_converter/ebooks/rtf2xml/colors.py
+++ b/ebook_converter/ebooks/rtf2xml/colors.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/combine_borders.py b/ebook_converter/ebooks/rtf2xml/combine_borders.py
index 547f7d7..d0a00e1 100644
--- a/ebook_converter/ebooks/rtf2xml/combine_borders.py
+++ b/ebook_converter/ebooks/rtf2xml/combine_borders.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/convert_to_tags.py b/ebook_converter/ebooks/rtf2xml/convert_to_tags.py
index b9c1175..7cef82f 100644
--- a/ebook_converter/ebooks/rtf2xml/convert_to_tags.py
+++ b/ebook_converter/ebooks/rtf2xml/convert_to_tags.py
@@ -1,8 +1,8 @@
from __future__ import unicode_literals, absolute_import, print_function, division
import os, sys
-from calibre.ebooks.rtf2xml import copy, check_encoding
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy, check_encoding
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
public_dtd = 'rtf2xml1.0.dtd'
diff --git a/ebook_converter/ebooks/rtf2xml/delete_info.py b/ebook_converter/ebooks/rtf2xml/delete_info.py
index fe92139..fcc2c95 100644
--- a/ebook_converter/ebooks/rtf2xml/delete_info.py
+++ b/ebook_converter/ebooks/rtf2xml/delete_info.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/fields_large.py b/ebook_converter/ebooks/rtf2xml/fields_large.py
index 6216217..0afaf4a 100644
--- a/ebook_converter/ebooks/rtf2xml/fields_large.py
+++ b/ebook_converter/ebooks/rtf2xml/fields_large.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import field_strings, copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import field_strings, copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/fields_small.py b/ebook_converter/ebooks/rtf2xml/fields_small.py
index d9ac4b7..baddc4a 100644
--- a/ebook_converter/ebooks/rtf2xml/fields_small.py
+++ b/ebook_converter/ebooks/rtf2xml/fields_small.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import field_strings, copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import field_strings, copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/fonts.py b/ebook_converter/ebooks/rtf2xml/fonts.py
index 20c6151..42c6a84 100644
--- a/ebook_converter/ebooks/rtf2xml/fonts.py
+++ b/ebook_converter/ebooks/rtf2xml/fonts.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/footnote.py b/ebook_converter/ebooks/rtf2xml/footnote.py
index 36e7624..31165a9 100644
--- a/ebook_converter/ebooks/rtf2xml/footnote.py
+++ b/ebook_converter/ebooks/rtf2xml/footnote.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/group_borders.py b/ebook_converter/ebooks/rtf2xml/group_borders.py
index bc34c99..2169469 100644
--- a/ebook_converter/ebooks/rtf2xml/group_borders.py
+++ b/ebook_converter/ebooks/rtf2xml/group_borders.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/group_styles.py b/ebook_converter/ebooks/rtf2xml/group_styles.py
index e0c0b44..a33fba2 100644
--- a/ebook_converter/ebooks/rtf2xml/group_styles.py
+++ b/ebook_converter/ebooks/rtf2xml/group_styles.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/header.py b/ebook_converter/ebooks/rtf2xml/header.py
index 05a4783..53bb796 100644
--- a/ebook_converter/ebooks/rtf2xml/header.py
+++ b/ebook_converter/ebooks/rtf2xml/header.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/headings_to_sections.py b/ebook_converter/ebooks/rtf2xml/headings_to_sections.py
index f9bc59b..ec64fd2 100644
--- a/ebook_converter/ebooks/rtf2xml/headings_to_sections.py
+++ b/ebook_converter/ebooks/rtf2xml/headings_to_sections.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py b/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py
index 71d0f25..2f252d3 100644
--- a/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py
+++ b/ebook_converter/ebooks/rtf2xml/hex_2_utf8.py
@@ -13,10 +13,10 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys, os, io
-from calibre.ebooks.rtf2xml import get_char_map, copy
-from calibre.ebooks.rtf2xml.char_set import char_set
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import get_char_map, copy
+from ebook_converter.ebooks.rtf2xml.char_set import char_set
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/info.py b/ebook_converter/ebooks/rtf2xml/info.py
index 37a1bf7..291fad8 100644
--- a/ebook_converter/ebooks/rtf2xml/info.py
+++ b/ebook_converter/ebooks/rtf2xml/info.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/inline.py b/ebook_converter/ebooks/rtf2xml/inline.py
index 301c7ea..cb9538b 100644
--- a/ebook_converter/ebooks/rtf2xml/inline.py
+++ b/ebook_converter/ebooks/rtf2xml/inline.py
@@ -1,8 +1,8 @@
from __future__ import unicode_literals, absolute_import, print_function, division
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
"""
diff --git a/ebook_converter/ebooks/rtf2xml/line_endings.py b/ebook_converter/ebooks/rtf2xml/line_endings.py
index 4660097..609faf0 100644
--- a/ebook_converter/ebooks/rtf2xml/line_endings.py
+++ b/ebook_converter/ebooks/rtf2xml/line_endings.py
@@ -13,9 +13,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.utils.cleantext import clean_ascii_chars
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.utils.cleantext import clean_ascii_chars
+from ebook_converter.ptempfile import better_mktemp
class FixLineEndings:
diff --git a/ebook_converter/ebooks/rtf2xml/list_numbers.py b/ebook_converter/ebooks/rtf2xml/list_numbers.py
index 7e074f1..b37bfb7 100644
--- a/ebook_converter/ebooks/rtf2xml/list_numbers.py
+++ b/ebook_converter/ebooks/rtf2xml/list_numbers.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/list_table.py b/ebook_converter/ebooks/rtf2xml/list_table.py
index 8688430..aabbca1 100644
--- a/ebook_converter/ebooks/rtf2xml/list_table.py
+++ b/ebook_converter/ebooks/rtf2xml/list_table.py
@@ -12,7 +12,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
# #
#########################################################################
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
class ListTable:
diff --git a/ebook_converter/ebooks/rtf2xml/make_lists.py b/ebook_converter/ebooks/rtf2xml/make_lists.py
index 7cfd07b..aa73cac 100644
--- a/ebook_converter/ebooks/rtf2xml/make_lists.py
+++ b/ebook_converter/ebooks/rtf2xml/make_lists.py
@@ -13,9 +13,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/old_rtf.py b/ebook_converter/ebooks/rtf2xml/old_rtf.py
index 65137b5..9b7ab31 100644
--- a/ebook_converter/ebooks/rtf2xml/old_rtf.py
+++ b/ebook_converter/ebooks/rtf2xml/old_rtf.py
@@ -13,7 +13,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read
diff --git a/ebook_converter/ebooks/rtf2xml/output.py b/ebook_converter/ebooks/rtf2xml/output.py
index 7e653fe..7499259 100644
--- a/ebook_converter/ebooks/rtf2xml/output.py
+++ b/ebook_converter/ebooks/rtf2xml/output.py
@@ -12,7 +12,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import sys, os
-from polyglot.builtins import raw_input
+from ebook_converter.polyglot.builtins import raw_input
from . import open_for_read, open_for_write
# , codecs
diff --git a/ebook_converter/ebooks/rtf2xml/paragraph_def.py b/ebook_converter/ebooks/rtf2xml/paragraph_def.py
index f5aab5d..296b4d4 100644
--- a/ebook_converter/ebooks/rtf2xml/paragraph_def.py
+++ b/ebook_converter/ebooks/rtf2xml/paragraph_def.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy, border_parse
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy, border_parse
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/paragraphs.py b/ebook_converter/ebooks/rtf2xml/paragraphs.py
index 5962c92..194a850 100644
--- a/ebook_converter/ebooks/rtf2xml/paragraphs.py
+++ b/ebook_converter/ebooks/rtf2xml/paragraphs.py
@@ -13,8 +13,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/pict.py b/ebook_converter/ebooks/rtf2xml/pict.py
index f3b1f74..30e497f 100644
--- a/ebook_converter/ebooks/rtf2xml/pict.py
+++ b/ebook_converter/ebooks/rtf2xml/pict.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/preamble_div.py b/ebook_converter/ebooks/rtf2xml/preamble_div.py
index cd7bcbe..dbd56b0 100644
--- a/ebook_converter/ebooks/rtf2xml/preamble_div.py
+++ b/ebook_converter/ebooks/rtf2xml/preamble_div.py
@@ -13,8 +13,8 @@ from __future__ import print_function
# #
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy, override_table, list_table
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy, override_table, list_table
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/preamble_rest.py b/ebook_converter/ebooks/rtf2xml/preamble_rest.py
index 9a82879..aec9b83 100644
--- a/ebook_converter/ebooks/rtf2xml/preamble_rest.py
+++ b/ebook_converter/ebooks/rtf2xml/preamble_rest.py
@@ -13,7 +13,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import sys,os
-from calibre.ebooks.rtf2xml import copy
+from ebook_converter.ebooks.rtf2xml import copy
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/process_tokens.py b/ebook_converter/ebooks/rtf2xml/process_tokens.py
index e64fba4..eab2703 100644
--- a/ebook_converter/ebooks/rtf2xml/process_tokens.py
+++ b/ebook_converter/ebooks/rtf2xml/process_tokens.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import os, re
-from calibre.ebooks.rtf2xml import copy, check_brackets
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy, check_brackets
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/sections.py b/ebook_converter/ebooks/rtf2xml/sections.py
index fdc0ed4..c4fa78c 100644
--- a/ebook_converter/ebooks/rtf2xml/sections.py
+++ b/ebook_converter/ebooks/rtf2xml/sections.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/styles.py b/ebook_converter/ebooks/rtf2xml/styles.py
index d86e267..4c1513c 100644
--- a/ebook_converter/ebooks/rtf2xml/styles.py
+++ b/ebook_converter/ebooks/rtf2xml/styles.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy, border_parse
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy, border_parse
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/table.py b/ebook_converter/ebooks/rtf2xml/table.py
index 139dea4..5f09753 100644
--- a/ebook_converter/ebooks/rtf2xml/table.py
+++ b/ebook_converter/ebooks/rtf2xml/table.py
@@ -13,9 +13,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
#########################################################################
import sys, os
-from calibre.ebooks.rtf2xml import copy, border_parse
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.rtf2xml import copy, border_parse
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import unicode_type
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/rtf2xml/table_info.py b/ebook_converter/ebooks/rtf2xml/table_info.py
index cb4bc5e..fbaaedc 100644
--- a/ebook_converter/ebooks/rtf2xml/table_info.py
+++ b/ebook_converter/ebooks/rtf2xml/table_info.py
@@ -12,8 +12,8 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# #
#########################################################################
import os
-from calibre.ebooks.rtf2xml import copy
-from calibre.ptempfile import better_mktemp
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.ptempfile import better_mktemp
from . import open_for_read, open_for_write
# note to self. This is the first module in which I use tempfile. A good idea?
diff --git a/ebook_converter/ebooks/rtf2xml/tokenize.py b/ebook_converter/ebooks/rtf2xml/tokenize.py
index be7d6b2..36a34e2 100644
--- a/ebook_converter/ebooks/rtf2xml/tokenize.py
+++ b/ebook_converter/ebooks/rtf2xml/tokenize.py
@@ -13,10 +13,10 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
#########################################################################
import os, re
-from calibre.ebooks.rtf2xml import copy
-from calibre.utils.mreplace import MReplace
-from calibre.ptempfile import better_mktemp
-from polyglot.builtins import codepoint_to_chr, range, filter, map
+from ebook_converter.ebooks.rtf2xml import copy
+from ebook_converter.utils.mreplace import MReplace
+from ebook_converter.ptempfile import better_mktemp
+from ebook_converter.polyglot.builtins import codepoint_to_chr, range, filter, map
from . import open_for_read, open_for_write
diff --git a/ebook_converter/ebooks/txt/__init__.py b/ebook_converter/ebooks/txt/__init__.py
index 5d05174..e69de29 100644
--- a/ebook_converter/ebooks/txt/__init__.py
+++ b/ebook_converter/ebooks/txt/__init__.py
@@ -1,10 +0,0 @@
-#!/usr/bin/env python2
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2008, John Schember john@nachtimwald.com'
-__docformat__ = 'restructuredtext en'
-
-'''
-Used for txt output
-'''
diff --git a/ebook_converter/ebooks/txt/processor.py b/ebook_converter/ebooks/txt/processor.py
index dbe6dfe..66a18f2 100644
--- a/ebook_converter/ebooks/txt/processor.py
+++ b/ebook_converter/ebooks/txt/processor.py
@@ -12,12 +12,12 @@ Read content from txt file.
import os, re
-from calibre import prepare_string_for_xml, isbytestring
-from calibre.ebooks.metadata.opf2 import OPFCreator
+from ebook_converter import prepare_string_for_xml, isbytestring
+from ebook_converter.ebooks.metadata.opf2 import OPFCreator
-from calibre.ebooks.conversion.preprocess import DocAnalysis
-from calibre.utils.cleantext import clean_ascii_chars
-from polyglot.builtins import iteritems, unicode_type, map, range, long_type
+from ebook_converter.ebooks.conversion.preprocess import DocAnalysis
+from ebook_converter.utils.cleantext import clean_ascii_chars
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, map, range, long_type
HTML_TEMPLATE = '%s \n%s\n'
@@ -111,7 +111,7 @@ DEFAULT_MD_EXTENSIONS = ('footnotes', 'tables', 'toc')
def create_markdown_object(extensions):
# Need to load markdown extensions without relying on pkg_resources
import importlib
- from calibre.ebooks.markdown import Markdown
+ from ebook_converter.ebooks.markdown import Markdown
from markdown import Extension
class NotBrainDeadMarkdown(Markdown):
@@ -127,7 +127,7 @@ def create_markdown_object(extensions):
return x(**configs)
raise ImportError('No extension class in {}'.format(ext_name))
- from calibre.ebooks.conversion.plugins.txt_input import MD_EXTENSIONS
+ from ebook_converter.ebooks.conversion.plugins.txt_input import MD_EXTENSIONS
extensions = [x.lower() for x in extensions]
extensions = [x for x in extensions if x in MD_EXTENSIONS]
md = NotBrainDeadMarkdown(extensions=extensions)
@@ -140,9 +140,9 @@ def convert_markdown(txt, title='', extensions=DEFAULT_MD_EXTENSIONS):
def convert_markdown_with_metadata(txt, title='', extensions=DEFAULT_MD_EXTENSIONS):
- from calibre.ebooks.metadata.book.base import Metadata
- from calibre.utils.date import parse_only_date
- from calibre.db.write import get_series_values
+ from ebook_converter.ebooks.metadata.book.base import Metadata
+ from ebook_converter.utils.date import parse_only_date
+ from ebook_converter.db.write import get_series_values
if 'meta' not in extensions:
extensions.append('meta')
md = create_markdown_object(extensions)
@@ -176,7 +176,7 @@ def convert_markdown_with_metadata(txt, title='', extensions=DEFAULT_MD_EXTENSIO
def convert_textile(txt, title=''):
- from calibre.ebooks.textile import textile
+ from ebook_converter.ebooks.textile import textile
html = textile(txt, encoding='utf-8')
return HTML_TEMPLATE % (title, html)
diff --git a/ebook_converter/ebooks/unihandecode/__init__.py b/ebook_converter/ebooks/unihandecode/__init__.py
index 91238ed..63e8120 100644
--- a/ebook_converter/ebooks/unihandecode/__init__.py
+++ b/ebook_converter/ebooks/unihandecode/__init__.py
@@ -29,16 +29,16 @@ class Unihandecoder(object):
self.preferred_encoding = encoding
lang = lang.lower()
if lang[:2] == 'ja':
- from calibre.ebooks.unihandecode.jadecoder import Jadecoder
+ from ebook_converter.ebooks.unihandecode.jadecoder import Jadecoder
self.decoder = Jadecoder()
elif lang[:2] == 'kr' or lang == 'korean':
- from calibre.ebooks.unihandecode.krdecoder import Krdecoder
+ from ebook_converter.ebooks.unihandecode.krdecoder import Krdecoder
self.decoder = Krdecoder()
elif lang[:2] == 'vn' or lang == 'vietnum':
- from calibre.ebooks.unihandecode.vndecoder import Vndecoder
+ from ebook_converter.ebooks.unihandecode.vndecoder import Vndecoder
self.decoder = Vndecoder()
else: # zh and others
- from calibre.ebooks.unihandecode.unidecoder import Unidecoder
+ from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder
self.decoder = Unidecoder()
def decode(self, text):
diff --git a/ebook_converter/ebooks/unihandecode/jadecoder.py b/ebook_converter/ebooks/unihandecode/jadecoder.py
index d6318c2..a4c54bd 100644
--- a/ebook_converter/ebooks/unihandecode/jadecoder.py
+++ b/ebook_converter/ebooks/unihandecode/jadecoder.py
@@ -20,10 +20,10 @@ Copyright (c) 2010 Hiroshi Miura
'''
import re
-from calibre.ebooks.unihandecode.unidecoder import Unidecoder
-from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS
-from calibre.ebooks.unihandecode.jacodepoints import CODEPOINTS as JACODES
-from calibre.ebooks.unihandecode.pykakasi.kakasi import kakasi
+from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder
+from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS
+from ebook_converter.ebooks.unihandecode.jacodepoints import CODEPOINTS as JACODES
+from ebook_converter.ebooks.unihandecode.pykakasi.kakasi import kakasi
class Jadecoder(Unidecoder):
diff --git a/ebook_converter/ebooks/unihandecode/krdecoder.py b/ebook_converter/ebooks/unihandecode/krdecoder.py
index 914f6f4..7cbacb9 100644
--- a/ebook_converter/ebooks/unihandecode/krdecoder.py
+++ b/ebook_converter/ebooks/unihandecode/krdecoder.py
@@ -11,9 +11,9 @@ Based on unidecoder.
'''
-from calibre.ebooks.unihandecode.unidecoder import Unidecoder
-from calibre.ebooks.unihandecode.krcodepoints import CODEPOINTS as HANCODES
-from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS
+from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder
+from ebook_converter.ebooks.unihandecode.krcodepoints import CODEPOINTS as HANCODES
+from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS
class Krdecoder(Unidecoder):
diff --git a/ebook_converter/ebooks/unihandecode/unidecoder.py b/ebook_converter/ebooks/unihandecode/unidecoder.py
index e66a11d..92d5638 100644
--- a/ebook_converter/ebooks/unihandecode/unidecoder.py
+++ b/ebook_converter/ebooks/unihandecode/unidecoder.py
@@ -61,9 +61,9 @@ it under the same terms as Perl itself.
'''
import re
-from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS
-from calibre.ebooks.unihandecode.zhcodepoints import CODEPOINTS as HANCODES
-from polyglot.builtins import unicode_type
+from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS
+from ebook_converter.ebooks.unihandecode.zhcodepoints import CODEPOINTS as HANCODES
+from ebook_converter.polyglot.builtins import unicode_type
class Unidecoder(object):
diff --git a/ebook_converter/ebooks/unihandecode/vndecoder.py b/ebook_converter/ebooks/unihandecode/vndecoder.py
index 60ee7fb..1a23d0d 100644
--- a/ebook_converter/ebooks/unihandecode/vndecoder.py
+++ b/ebook_converter/ebooks/unihandecode/vndecoder.py
@@ -10,9 +10,9 @@ Decode unicode text to an ASCII representation of the text in Vietnamese.
'''
-from calibre.ebooks.unihandecode.unidecoder import Unidecoder
-from calibre.ebooks.unihandecode.vncodepoints import CODEPOINTS as HANCODES
-from calibre.ebooks.unihandecode.unicodepoints import CODEPOINTS
+from ebook_converter.ebooks.unihandecode.unidecoder import Unidecoder
+from ebook_converter.ebooks.unihandecode.vncodepoints import CODEPOINTS as HANCODES
+from ebook_converter.ebooks.unihandecode.unicodepoints import CODEPOINTS
class Vndecoder(Unidecoder):
diff --git a/ebook_converter/library/__init__.py b/ebook_converter/library/__init__.py
index 655ca84..7c1bc31 100644
--- a/ebook_converter/library/__init__.py
+++ b/ebook_converter/library/__init__.py
@@ -7,12 +7,12 @@ __copyright__ = '2008, Kovid Goyal '
import os
-from polyglot.builtins import range
+from ebook_converter.polyglot.builtins import range
def db(path=None, read_only=False):
- from calibre.db.legacy import LibraryDatabase
- from calibre.utils.config import prefs
+ from ebook_converter.db.legacy import LibraryDatabase
+ from ebook_converter.utils.config import prefs
return LibraryDatabase(os.path.expanduser(path) if path else prefs['library_path'],
read_only=read_only)
@@ -28,7 +28,7 @@ def generate_test_db(library_path, # {{{
max_tags=10
):
import random, string, os, sys, time
- from calibre.constants import preferred_encoding
+ from ebook_converter.constants import preferred_encoding
if not os.path.exists(library_path):
os.makedirs(library_path)
@@ -59,7 +59,7 @@ def generate_test_db(library_path, # {{{
authors = [random.choice(all_authors) for i in range(authors)]
tags = random.randint(0, max_tags)
tags = [random.choice(all_tags) for i in range(tags)]
- from calibre.ebooks.metadata.book.base import Metadata
+ from ebook_converter.ebooks.metadata.book.base import Metadata
mi = Metadata(title, authors)
mi.tags = tags
testdb.import_book(mi, [])
@@ -71,7 +71,7 @@ def generate_test_db(library_path, # {{{
def current_library_path():
- from calibre.utils.config import prefs
+ from ebook_converter.utils.config import prefs
path = prefs['library_path']
if path:
path = path.replace('\\', '/')
diff --git a/ebook_converter/library/catalogs/bibtex.py b/ebook_converter/library/catalogs/bibtex.py
index 17bc2b0..1ed6497 100644
--- a/ebook_converter/library/catalogs/bibtex.py
+++ b/ebook_converter/library/catalogs/bibtex.py
@@ -9,12 +9,12 @@ __docformat__ = 'restructuredtext en'
import re, codecs, os, numbers
from collections import namedtuple
-from calibre import strftime
-from calibre.customize import CatalogPlugin
-from calibre.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS
-from calibre.customize.conversion import DummyReporter
-from calibre.ebooks.metadata import format_isbn
-from polyglot.builtins import filter, string_or_bytes, unicode_type
+from ebook_converter import strftime
+from ebook_converter.customize import CatalogPlugin
+from ebook_converter.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS
+from ebook_converter.customize.conversion import DummyReporter
+from ebook_converter.ebooks.metadata import format_isbn
+from ebook_converter.polyglot.builtins import filter, string_or_bytes, unicode_type
class BIBTEX(CatalogPlugin):
@@ -108,12 +108,12 @@ class BIBTEX(CatalogPlugin):
"Applies to: BIBTEX output format"))]
def run(self, path_to_output, opts, db, notification=DummyReporter()):
- from calibre.utils.date import isoformat
- from calibre.utils.html2text import html2text
- from calibre.utils.bibtex import BibTeX
- from calibre.library.save_to_disk import preprocess_template
- from calibre.utils.logging import default_log as log
- from calibre.utils.filenames import ascii_text
+ from ebook_converter.utils.date import isoformat
+ from ebook_converter.utils.html2text import html2text
+ from ebook_converter.utils.bibtex import BibTeX
+ from ebook_converter.library.save_to_disk import preprocess_template
+ from ebook_converter.utils.logging import default_log as log
+ from ebook_converter.utils.filenames import ascii_text
library_name = os.path.basename(db.library_path)
diff --git a/ebook_converter/library/catalogs/csv_xml.py b/ebook_converter/library/catalogs/csv_xml.py
index e80c027..4594f72 100644
--- a/ebook_converter/library/catalogs/csv_xml.py
+++ b/ebook_converter/library/catalogs/csv_xml.py
@@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
import re, codecs, os
from collections import namedtuple
-from calibre.customize import CatalogPlugin
-from calibre.library.catalogs import FIELDS
-from calibre.customize.conversion import DummyReporter
-from polyglot.builtins import unicode_type
+from ebook_converter.customize import CatalogPlugin
+from ebook_converter.library.catalogs import FIELDS
+from ebook_converter.customize.conversion import DummyReporter
+from ebook_converter.polyglot.builtins import unicode_type
class CSV_XML(CatalogPlugin):
@@ -52,12 +52,12 @@ class CSV_XML(CatalogPlugin):
"Applies to: CSV, XML output formats"))]
def run(self, path_to_output, opts, db, notification=DummyReporter()):
- from calibre.library import current_library_name
- from calibre.utils.date import isoformat
- from calibre.utils.html2text import html2text
- from calibre.utils.logging import default_log as log
+ from ebook_converter.library import current_library_name
+ from ebook_converter.utils.date import isoformat
+ from ebook_converter.utils.html2text import html2text
+ from ebook_converter.utils.logging import default_log as log
from lxml import etree
- from calibre.ebooks.metadata import authors_to_string
+ from ebook_converter.ebooks.metadata import authors_to_string
self.fmt = path_to_output.rpartition('.')[2]
self.notification = notification
diff --git a/ebook_converter/library/catalogs/epub_mobi.py b/ebook_converter/library/catalogs/epub_mobi.py
index 112e7c9..f03ddf3 100644
--- a/ebook_converter/library/catalogs/epub_mobi.py
+++ b/ebook_converter/library/catalogs/epub_mobi.py
@@ -9,14 +9,14 @@ __docformat__ = 'restructuredtext en'
import datetime, os, time
from collections import namedtuple
-from calibre import strftime
-from calibre.customize import CatalogPlugin
-from calibre.customize.conversion import OptionRecommendation, DummyReporter
-from calibre.library import current_library_name
-from calibre.library.catalogs import AuthorSortMismatchException, EmptyCatalogException
-from calibre.ptempfile import PersistentTemporaryFile
-from calibre.utils.localization import calibre_langcode_to_name, canonicalize_lang, get_lang
-from polyglot.builtins import unicode_type
+from ebook_converter import strftime
+from ebook_converter.customize import CatalogPlugin
+from ebook_converter.customize.conversion import OptionRecommendation, DummyReporter
+from ebook_converter.library import current_library_name
+from ebook_converter.library.catalogs import AuthorSortMismatchException, EmptyCatalogException
+from ebook_converter.ptempfile import PersistentTemporaryFile
+from ebook_converter.utils.localization import calibre_langcode_to_name, canonicalize_lang, get_lang
+from ebook_converter.polyglot.builtins import unicode_type
Option = namedtuple('Option', 'option, default, dest, action, help')
@@ -191,9 +191,9 @@ class EPUB_MOBI(CatalogPlugin):
# }}}
def run(self, path_to_output, opts, db, notification=DummyReporter()):
- from calibre.library.catalogs.epub_mobi_builder import CatalogBuilder
- from calibre.utils.logging import default_log as log
- from calibre.utils.config import JSONConfig
+ from ebook_converter.library.catalogs.epub_mobi_builder import CatalogBuilder
+ from ebook_converter.utils.logging import default_log as log
+ from ebook_converter.utils.config import JSONConfig
# If preset specified from the cli, insert stored options from JSON file
if hasattr(opts, 'preset') and opts.preset:
@@ -465,7 +465,7 @@ class EPUB_MOBI(CatalogPlugin):
recommendations.append(('cover', cpath, OptionRecommendation.HIGH))
log.info("using existing catalog cover")
else:
- from calibre.ebooks.covers import calibre_cover2
+ from ebook_converter.ebooks.covers import calibre_cover2
log.info("replacing catalog cover")
new_cover_path = PersistentTemporaryFile(suffix='.jpg')
new_cover = calibre_cover2(opts.catalog_title, 'calibre')
@@ -474,7 +474,7 @@ class EPUB_MOBI(CatalogPlugin):
recommendations.append(('cover', new_cover_path.name, OptionRecommendation.HIGH))
# Run ebook-convert
- from calibre.ebooks.conversion.plumber import Plumber
+ from ebook_converter.ebooks.conversion.plumber import Plumber
plumber = Plumber(os.path.join(catalog.catalog_path, opts.basename + '.opf'),
path_to_output, log, report_progress=notification,
abort_after_input_dump=False)
@@ -487,9 +487,9 @@ class EPUB_MOBI(CatalogPlugin):
pass
if GENERATE_DEBUG_EPUB:
- from calibre.ebooks.epub import initialize_container
- from calibre.ebooks.tweak import zip_rebuilder
- from calibre.utils.zipfile import ZipFile
+ from ebook_converter.ebooks.epub import initialize_container
+ from ebook_converter.ebooks.tweak import zip_rebuilder
+ from ebook_converter.utils.zipfile import ZipFile
input_path = os.path.join(catalog_debug_path, 'input')
epub_shell = os.path.join(catalog_debug_path, 'epub_shell.zip')
initialize_container(epub_shell, opf_name='content.opf')
diff --git a/ebook_converter/library/comments.py b/ebook_converter/library/comments.py
index 344dd99..cc9082f 100644
--- a/ebook_converter/library/comments.py
+++ b/ebook_converter/library/comments.py
@@ -6,14 +6,14 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import re
-from calibre import prepare_string_for_xml
-from calibre.constants import preferred_encoding
-from calibre.ebooks.BeautifulSoup import (
+from ebook_converter import prepare_string_for_xml
+from ebook_converter.constants import preferred_encoding
+from ebook_converter.ebooks.BeautifulSoup import (
BeautifulSoup, CData, Comment, Declaration, NavigableString,
ProcessingInstruction
)
-from calibre.utils.html2text import html2text
-from polyglot.builtins import unicode_type
+from ebook_converter.utils.html2text import html2text
+from ebook_converter.polyglot.builtins import unicode_type
# Hackish - ignoring sentences ending or beginning in numbers to avoid
# confusion with decimal points.
@@ -135,7 +135,7 @@ def markdown(val):
try:
md = markdown.Markdown
except AttributeError:
- from calibre.ebooks.markdown import Markdown
+ from ebook_converter.ebooks.markdown import Markdown
md = markdown.Markdown = Markdown()
return md.convert(val)
@@ -145,7 +145,7 @@ def merge_comments(one, two):
def sanitize_comments_html(html):
- from calibre.ebooks.markdown import Markdown
+ from ebook_converter.ebooks.markdown import Markdown
text = html2text(html)
md = Markdown()
html = md.convert(text)
diff --git a/ebook_converter/library/field_metadata.py b/ebook_converter/library/field_metadata.py
index 5e385b9..ad597f9 100644
--- a/ebook_converter/library/field_metadata.py
+++ b/ebook_converter/library/field_metadata.py
@@ -9,8 +9,8 @@ Created on 25 May 2010
import traceback
from collections import OrderedDict
-from calibre.utils.config_base import tweaks
-from polyglot.builtins import iteritems, itervalues
+from ebook_converter.utils.config_base import tweaks
+from ebook_converter.polyglot.builtins import iteritems, itervalues
category_icon_map = {
'authors' : 'user_profile.png',
diff --git a/ebook_converter/main.py b/ebook_converter/main.py
new file mode 100644
index 0000000..597344e
--- /dev/null
+++ b/ebook_converter/main.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+import sys
+
+# TODO: remove this crap
+sys.resources_location = ''
+sys.extensions_location = '/usr/lib64/calibre/calibre/plugins'
+sys.executables_location = '/usr/bin'
+
+from ebook_converter.ebooks.conversion.cli import main
+
+
+def run():
+ sys.exit(main())
+
+
+if __name__ == '__main__':
+ run()
diff --git a/ebook_converter/polyglot/binary.py b/ebook_converter/polyglot/binary.py
index 360ac0b..417e958 100644
--- a/ebook_converter/polyglot/binary.py
+++ b/ebook_converter/polyglot/binary.py
@@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from base64 import standard_b64decode, standard_b64encode
from binascii import hexlify, unhexlify
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
def as_base64_bytes(x, enc='utf-8'):
diff --git a/ebook_converter/polyglot/functools.py b/ebook_converter/polyglot/functools.py
index f0cdf08..bb77c21 100644
--- a/ebook_converter/polyglot/functools.py
+++ b/ebook_converter/polyglot/functools.py
@@ -4,7 +4,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
-from polyglot.builtins import is_py3
+from ebook_converter.polyglot.builtins import is_py3
if is_py3:
from functools import lru_cache
else:
diff --git a/ebook_converter/polyglot/html_entities.py b/ebook_converter/polyglot/html_entities.py
index 2e20eee..90464c0 100644
--- a/ebook_converter/polyglot/html_entities.py
+++ b/ebook_converter/polyglot/html_entities.py
@@ -2,7 +2,7 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Eli Schwartz
-from polyglot.builtins import is_py3
+from ebook_converter.polyglot.builtins import is_py3
if is_py3:
from html.entities import name2codepoint
diff --git a/ebook_converter/polyglot/urllib.py b/ebook_converter/polyglot/urllib.py
index 1d30c99..11bce1f 100644
--- a/ebook_converter/polyglot/urllib.py
+++ b/ebook_converter/polyglot/urllib.py
@@ -4,7 +4,7 @@
from __future__ import absolute_import
-from polyglot.builtins import is_py3
+from ebook_converter.polyglot.builtins import is_py3
if is_py3:
from urllib.request import (build_opener, getproxies, install_opener, # noqa
diff --git a/ebook_converter/ptempfile.py b/ebook_converter/ptempfile.py
index 9d9bf81..d6a8a8a 100644
--- a/ebook_converter/ptempfile.py
+++ b/ebook_converter/ptempfile.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
"""
@@ -6,9 +5,9 @@ Provides platform independent temporary files that persist even after
being closed.
"""
import tempfile, os, atexit
-from polyglot.builtins import map, getenv
+from ebook_converter.polyglot.builtins import map, getenv
-from calibre.constants import (__version__, __appname__, filesystem_encoding,
+from ebook_converter.constants import (__version__, __appname__, filesystem_encoding,
iswindows, get_windows_temp_path, isosx, ispy3)
@@ -91,8 +90,8 @@ def base_dir():
if _base_dir is None:
td = os.environ.get('CALIBRE_WORKER_TEMP_DIR', None)
if td is not None:
- from calibre.utils.serialize import msgpack_loads
- from polyglot.binary import from_hex_bytes
+ from ebook_converter.utils.serialize import msgpack_loads
+ from ebook_converter.polyglot.binary import from_hex_bytes
try:
td = msgpack_loads(from_hex_bytes(td))
except Exception:
diff --git a/ebook_converter/spell/__init__.py b/ebook_converter/spell/__init__.py
index e58ae8f..ed92137 100644
--- a/ebook_converter/spell/__init__.py
+++ b/ebook_converter/spell/__init__.py
@@ -7,7 +7,7 @@ __copyright__ = '2014, Kovid Goyal '
from collections import namedtuple
-from calibre.utils.localization import canonicalize_lang
+from ebook_converter.utils.localization import canonicalize_lang
DictionaryLocale = namedtuple('DictionaryLocale', 'langcode countrycode')
@@ -17,7 +17,7 @@ ccodes, ccodemap, country_names = None, None, None
def get_codes():
global ccodes, ccodemap, country_names
if ccodes is None:
- from calibre.utils.serialize import msgpack_loads
+ from ebook_converter.utils.serialize import msgpack_loads
data = msgpack_loads(P('localization/iso3166.calibre_msgpack', allow_user_override=False, data=True))
ccodes, ccodemap, country_names = data['codes'], data['three_map'], data['names']
return ccodes, ccodemap
diff --git a/ebook_converter/startup.py b/ebook_converter/startup.py
index 7508b24..beb9bf8 100644
--- a/ebook_converter/startup.py
+++ b/ebook_converter/startup.py
@@ -1,4 +1,3 @@
-from __future__ import print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
@@ -10,7 +9,7 @@ Perform various initialization tasks.
import locale, sys, os
# Default translation is NOOP
-from polyglot.builtins import builtins, is_py3, unicode_type
+from ebook_converter.polyglot.builtins import builtins, is_py3, unicode_type
builtins.__dict__['_'] = lambda s: s
# For strings which belong in the translation tables, but which shouldn't be
@@ -21,7 +20,7 @@ builtins.__dict__['__'] = lambda s: s
builtins.__dict__['dynamic_property'] = lambda func: func(None)
-from calibre.constants import iswindows, preferred_encoding, plugins, isosx, islinux, isfrozen, DEBUG, isfreebsd, ispy3
+from ebook_converter.constants import iswindows, preferred_encoding, plugins, isosx, islinux, isfrozen, DEBUG, isfreebsd, ispy3
_run_once = False
winutil = winutilerror = None
@@ -99,7 +98,7 @@ if not _run_once:
os.path.expanduser = expanduser
# Ensure that all temp files/dirs are created under a calibre tmp dir
- from calibre.ptempfile import base_dir
+ from ebook_converter.ptempfile import base_dir
try:
base_dir()
except EnvironmentError:
@@ -133,12 +132,12 @@ if not _run_once:
#
# Setup resources
- import calibre.utils.resources as resources
+ import ebook_converter.utils.resources as resources
resources
#
# Setup translations
- from calibre.utils.localization import set_translators
+ from ebook_converter.utils.localization import set_translators
set_translators()
@@ -201,7 +200,7 @@ if not _run_once:
builtins.__dict__['lopen'] = local_open
- from calibre.utils.icu import title_case, lower as icu_lower, upper as icu_upper
+ from ebook_converter.utils.icu import title_case, lower as icu_lower, upper as icu_upper
builtins.__dict__['icu_lower'] = icu_lower
builtins.__dict__['icu_upper'] = icu_upper
builtins.__dict__['icu_title'] = title_case
@@ -249,8 +248,8 @@ if not _run_once:
def test_lopen():
- from calibre.ptempfile import TemporaryDirectory
- from calibre import CurrentDir
+ from ebook_converter.ptempfile import TemporaryDirectory
+ from ebook_converter import CurrentDir
n = 'f\xe4llen'
print('testing lopen()')
diff --git a/ebook_converter/tinycss/__init__.py b/ebook_converter/tinycss/__init__.py
index 73451ba..0ec8afe 100644
--- a/ebook_converter/tinycss/__init__.py
+++ b/ebook_converter/tinycss/__init__.py
@@ -15,7 +15,7 @@ __version__ = VERSION
from tinycss.css21 import CSS21Parser
from tinycss.page3 import CSSPage3Parser
from tinycss.fonts3 import CSSFonts3Parser
-from tinycss.media3 import CSSMedia3Parser
+from ebook_converter.tinycss.media3 import CSSMedia3Parser
PARSER_MODULES = {
diff --git a/ebook_converter/tinycss/fonts3.py b/ebook_converter/tinycss/fonts3.py
index 60030b7..d55e8dd 100644
--- a/ebook_converter/tinycss/fonts3.py
+++ b/ebook_converter/tinycss/fonts3.py
@@ -7,9 +7,9 @@ __copyright__ = '2014, Kovid Goyal '
import re
-from polyglot.builtins import map
+from ebook_converter.polyglot.builtins import map
from tinycss.css21 import CSS21Parser, ParseError
-from .tokenizer import tokenize_grouped
+from tinycss.tokenizer import tokenize_grouped
def parse_font_family_tokens(tokens):
diff --git a/ebook_converter/tinycss/media3.py b/ebook_converter/tinycss/media3.py
index 3d4ebe1..9498c78 100644
--- a/ebook_converter/tinycss/media3.py
+++ b/ebook_converter/tinycss/media3.py
@@ -7,7 +7,7 @@ __copyright__ = '2014, Kovid Goyal '
from tinycss.css21 import CSS21Parser
from tinycss.parsing import remove_whitespace, split_on_comma, ParseError
-from polyglot.builtins import error_message
+from ebook_converter.polyglot.builtins import error_message
class MediaQuery(object):
diff --git a/ebook_converter/translations/__init__.py b/ebook_converter/translations/__init__.py
index bb409a2..e69de29 100644
--- a/ebook_converter/translations/__init__.py
+++ b/ebook_converter/translations/__init__.py
@@ -1 +0,0 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
diff --git a/ebook_converter/translations/dynamic.py b/ebook_converter/translations/dynamic.py
index e55e5bb..6f02287 100644
--- a/ebook_converter/translations/dynamic.py
+++ b/ebook_converter/translations/dynamic.py
@@ -8,8 +8,8 @@ __copyright__ = '2008, Marshall T. Vandegrift '
import io
from gettext import GNUTranslations
-from calibre.constants import ispy3
-from calibre.utils.localization import get_lc_messages_path
+from ebook_converter.constants import ispy3
+from ebook_converter.utils.localization import get_lc_messages_path
from zipfile import ZipFile
__all__ = ['translate']
diff --git a/ebook_converter/utils/__init__.py b/ebook_converter/utils/__init__.py
index ca4af88..e69de29 100644
--- a/ebook_converter/utils/__init__.py
+++ b/ebook_converter/utils/__init__.py
@@ -1,56 +0,0 @@
-#!/usr/bin/env python2
-
-from __future__ import absolute_import, division, print_function, unicode_literals
-
-__license__ = 'GPL v3'
-__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
-__docformat__ = 'restructuredtext en'
-
-'''
-Miscelleaneous utilities.
-'''
-
-from time import time
-from polyglot.builtins import as_bytes
-
-
-def join_with_timeout(q, timeout=2):
- ''' Join the queue q with a specified timeout. Blocks until all tasks on
- the queue are done or times out with a runtime error. '''
- q.all_tasks_done.acquire()
- try:
- endtime = time() + timeout
- while q.unfinished_tasks:
- remaining = endtime - time()
- if remaining <= 0.0:
- raise RuntimeError('Waiting for queue to clear timed out')
- q.all_tasks_done.wait(remaining)
- finally:
- q.all_tasks_done.release()
-
-
-def unpickle_binary_string(data):
- # Maintains compatibility with python's pickle module protocol version 2
- import struct
- PROTO, SHORT_BINSTRING, BINSTRING = b'\x80', b'U', b'T'
- if data.startswith(PROTO + b'\x02'):
- offset = 2
- which = data[offset:offset+1]
- offset += 1
- if which == BINSTRING:
- sz, = struct.unpack_from(''
-__docformat__ = 'restructuredtext en'
diff --git a/ebook_converter/utils/fonts/metadata.py b/ebook_converter/utils/fonts/metadata.py
index aad632d..135e5c6 100644
--- a/ebook_converter/utils/fonts/metadata.py
+++ b/ebook_converter/utils/fonts/metadata.py
@@ -10,8 +10,8 @@ from io import BytesIO
from struct import calcsize, unpack, unpack_from
from collections import namedtuple
-from calibre.utils.fonts.utils import get_font_names2, get_font_characteristics
-from polyglot.builtins import range, unicode_type
+from ebook_converter.utils.fonts.utils import get_font_names2, get_font_characteristics
+from ebook_converter.polyglot.builtins import range, unicode_type
class UnsupportedFont(ValueError):
diff --git a/ebook_converter/utils/fonts/scanner.py b/ebook_converter/utils/fonts/scanner.py
index 862b537..eed0728 100644
--- a/ebook_converter/utils/fonts/scanner.py
+++ b/ebook_converter/utils/fonts/scanner.py
@@ -10,12 +10,11 @@ import os
from collections import defaultdict
from threading import Thread
-from calibre import walk, prints, as_unicode
-from calibre.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
+from ebook_converter import walk, prints, as_unicode
+from ebook_converter.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
isworker, filesystem_encoding)
-from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
-from calibre.utils.icu import sort_key
-from polyglot.builtins import itervalues, unicode_type, filter
+from ebook_converter.utils.fonts.metadata import FontMetadata, UnsupportedFont
+from ebook_converter.polyglot.builtins import itervalues, unicode_type, filter
class NoFonts(ValueError):
@@ -153,12 +152,12 @@ def path_significance(path, folders):
def build_families(cached_fonts, folders, family_attr='font-family'):
families = defaultdict(list)
- for f in itervalues(cached_fonts):
- if not f:
+ for font in itervalues(cached_fonts):
+ if not font:
continue
- lf = icu_lower(f.get(family_attr) or '')
+ lf = (font.get(family_attr) or '').lower()
if lf:
- families[lf].append(f)
+ families[lf].append(font)
for fonts in itervalues(families):
# Look for duplicate font files and choose the copy that is from a
@@ -166,26 +165,26 @@ def build_families(cached_fonts, folders, family_attr='font-family'):
# system directories).
fmap = {}
remove = []
- for f in fonts:
- fingerprint = (icu_lower(f['font-family']), f['font-weight'],
- f['font-stretch'], f['font-style'])
+ for font in fonts:
+ fingerprint = (font['font-family'].lower(), font['font-weight'],
+ font['font-stretch'], font['font-style'])
if fingerprint in fmap:
opath = fmap[fingerprint]['path']
- npath = f['path']
+ npath = font['path']
if path_significance(npath, folders) >= path_significance(opath, folders):
remove.append(fmap[fingerprint])
- fmap[fingerprint] = f
+ fmap[fingerprint] = font
else:
- remove.append(f)
+ remove.append(font)
else:
- fmap[fingerprint] = f
- for font in remove:
- fonts.remove(font)
+ fmap[fingerprint] = font
+ for fnt in remove:
+ fonts.remove(fnt)
fonts.sort(key=font_priority)
font_family_map = dict.copy(families)
- font_families = tuple(sorted((f[0]['font-family'] for f in
- itervalues(font_family_map)), key=sort_key))
+ font_families = tuple(sorted((font[0]['font-family'] for font in
+ itervalues(font_family_map))))
return font_family_map, font_families
# }}}
@@ -198,8 +197,8 @@ class FontScanner(Thread):
Thread.__init__(self)
self.folders = folders + font_dirs() + [os.path.join(config_dir, 'fonts'),
P('fonts/liberation')]
- self.folders = [os.path.normcase(os.path.abspath(f)) for f in
- self.folders]
+ self.folders = [os.path.normcase(os.path.abspath(font)) for font in
+ self.folders]
self.font_families = ()
self.allowed_extensions = allowed_extensions
@@ -218,7 +217,7 @@ class FontScanner(Thread):
'''
self.join()
try:
- return self.font_family_map[icu_lower(family)]
+ return self.font_family_map[family.lower()]
except KeyError:
raise NoFonts('No fonts found for the family: %r'%family)
@@ -264,7 +263,7 @@ class FontScanner(Thread):
:return: (family name, faces) or None, None
'''
- from calibre.utils.fonts.utils import (supports_text,
+ from ebook_converter.utils.fonts.utils import (supports_text,
panose_to_css_generic_family, get_printable_characters)
if not isinstance(text, unicode_type):
raise TypeError(u'%r is not unicode'%text)
@@ -297,7 +296,7 @@ class FontScanner(Thread):
def reload_cache(self):
if not hasattr(self, 'cache'):
- from calibre.utils.config import JSONConfig
+ from ebook_converter.utils.config import JSONConfig
self.cache = JSONConfig('fonts/scanner_cache')
else:
self.cache.refresh()
diff --git a/ebook_converter/utils/fonts/utils.py b/ebook_converter/utils/fonts/utils.py
index fd59876..a1ef2e4 100644
--- a/ebook_converter/utils/fonts/utils.py
+++ b/ebook_converter/utils/fonts/utils.py
@@ -10,7 +10,7 @@ import struct
from io import BytesIO
from collections import defaultdict
-from polyglot.builtins import iteritems, itervalues, unicode_type, range, as_bytes
+from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type, range, as_bytes
class UnsupportedFont(ValueError):
@@ -441,7 +441,7 @@ def get_font_for_text(text, candidate_font_data=None):
if candidate_font_data is not None:
ok = supports_text(candidate_font_data, text)
if not ok:
- from calibre.utils.fonts.scanner import font_scanner
+ from ebook_converter.utils.fonts.scanner import font_scanner
family, faces = font_scanner.find_font_for_text(text)
if faces:
with lopen(faces[0]['path'], 'rb') as f:
@@ -450,7 +450,7 @@ def get_font_for_text(text, candidate_font_data=None):
def test_glyph_ids():
- from calibre.utils.fonts.free_type import FreeType
+ from ebook_converter.utils.fonts.free_type import FreeType
data = P('fonts/liberation/LiberationSerif-Regular.ttf', data=True)
ft = FreeType()
font = ft.load_font(data)
@@ -470,7 +470,7 @@ def test_supports_text():
def test_find_font():
- from calibre.utils.fonts.scanner import font_scanner
+ from ebook_converter.utils.fonts.scanner import font_scanner
abcd = '诶比西迪'
family = font_scanner.find_font_for_text(abcd)[0]
print('Family for Chinese text:', family)
diff --git a/ebook_converter/utils/formatter.py b/ebook_converter/utils/formatter.py
index a82e08c..e7379db 100644
--- a/ebook_converter/utils/formatter.py
+++ b/ebook_converter/utils/formatter.py
@@ -11,10 +11,10 @@ __docformat__ = 'restructuredtext en'
import re, string, traceback, numbers
-from calibre import prints
-from calibre.constants import DEBUG
-from calibre.utils.formatter_functions import formatter_functions
-from polyglot.builtins import unicode_type, error_message
+from ebook_converter import prints
+from ebook_converter.constants import DEBUG
+from ebook_converter.utils.formatter_functions import formatter_functions
+from ebook_converter.polyglot.builtins import unicode_type, error_message
class _Parser(object):
@@ -393,7 +393,7 @@ class ValidateFormatter(TemplateFormatter):
return self._validation_string
def validate(self, x):
- from calibre.ebooks.metadata.book.base import Metadata
+ from ebook_converter.ebooks.metadata.book.base import Metadata
return self.safe_format(x, {}, 'VALIDATE ERROR', Metadata(''))
diff --git a/ebook_converter/utils/formatter_functions.py b/ebook_converter/utils/formatter_functions.py
index ccf96b1..e5026c8 100644
--- a/ebook_converter/utils/formatter_functions.py
+++ b/ebook_converter/utils/formatter_functions.py
@@ -15,15 +15,15 @@ __docformat__ = 'restructuredtext en'
import inspect, re, traceback, numbers
from math import trunc
-from calibre import human_readable
-from calibre.constants import DEBUG
-from calibre.ebooks.metadata import title_sort
-from calibre.utils.config import tweaks
-from calibre.utils.titlecase import titlecase
-from calibre.utils.icu import capitalize, strcmp, sort_key
-from calibre.utils.date import parse_date, format_date, now, UNDEFINED_DATE
-from calibre.utils.localization import calibre_langcode_to_name, canonicalize_lang
-from polyglot.builtins import iteritems, itervalues, unicode_type
+from ebook_converter import human_readable
+from ebook_converter.constants import DEBUG
+from ebook_converter.ebooks.metadata import title_sort
+from ebook_converter.utils.config import tweaks
+from ebook_converter.utils.titlecase import titlecase
+from ebook_converter.utils.icu import capitalize, strcmp, sort_key
+from ebook_converter.utils.date import parse_date, format_date, now, UNDEFINED_DATE
+from ebook_converter.utils.localization import calibre_langcode_to_name, canonicalize_lang
+from ebook_converter.polyglot.builtins import iteritems, itervalues, unicode_type
class FormatterFunctions(object):
@@ -321,7 +321,7 @@ class BuiltinEval(BuiltinFormatterFunction):
'template program mode.')
def evaluate(self, formatter, kwargs, mi, locals, template):
- from calibre.utils.formatter import EvalFormatter
+ from ebook_converter.utils.formatter import EvalFormatter
template = template.replace('[[', '{').replace(']]', '}')
return EvalFormatter().safe_format(template, locals, 'EVAL', None)
@@ -644,7 +644,7 @@ class BuiltinReGroup(BuiltinFormatterFunction):
"{series:'re_group($, \"(\\S* )(.*)\", \"[[$:uppercase()]]\", \"[[$]]\")'}")
def evaluate(self, formatter, kwargs, mi, locals, val, pattern, *args):
- from calibre.utils.formatter import EvalFormatter
+ from ebook_converter.utils.formatter import EvalFormatter
def repl(mo):
res = ''
@@ -1348,7 +1348,7 @@ class BuiltinListReGroup(BuiltinFormatterFunction):
def evaluate(self, formatter, kwargs, mi, locals, src_list, separator, include_re,
search_re, *args):
- from calibre.utils.formatter import EvalFormatter
+ from ebook_converter.utils.formatter import EvalFormatter
l = [l.strip() for l in src_list.split(separator) if l.strip()]
res = []
@@ -1467,7 +1467,7 @@ class BuiltinCurrentLibraryName(BuiltinFormatterFunction):
'template "{:\'current_library_name()\'}".')
def evaluate(self, formatter, kwargs, mi, locals):
- from calibre.library import current_library_name
+ from ebook_converter.library import current_library_name
return current_library_name()
@@ -1481,7 +1481,7 @@ class BuiltinCurrentLibraryPath(BuiltinFormatterFunction):
'"{:\'current_library_path()\'}".')
def evaluate(self, formatter, kwargs, mi, locals):
- from calibre.library import current_library_path
+ from ebook_converter.library import current_library_path
return current_library_path()
@@ -1551,7 +1551,7 @@ class BuiltinTransliterate(BuiltinFormatterFunction):
u"Фёдор Миха́йлович Достоевский", 'Fiodor Mikhailovich Dostoievskii')
def evaluate(self, formatter, kwargs, mi, locals, source):
- from calibre.utils.filenames import ascii_text
+ from ebook_converter.utils.filenames import ascii_text
return ascii_text(source)
@@ -1648,8 +1648,8 @@ def compile_user_function(name, doc, arg_count, eval_func):
func = ' ' + '\n '.join([tabs.sub(replace_func, line)
for line in eval_func.splitlines()])
prog = '''
-from calibre.utils.formatter_functions import FormatterUserFunction
-from calibre.utils.formatter_functions import formatter_functions
+from ebook_converter.utils.formatter_functions import FormatterUserFunction
+from ebook_converter.utils.formatter_functions import formatter_functions
class UserFunction(FormatterUserFunction):
''' + func
locals_ = {}
diff --git a/ebook_converter/utils/html2text.py b/ebook_converter/utils/html2text.py
index fd83235..b17e223 100644
--- a/ebook_converter/utils/html2text.py
+++ b/ebook_converter/utils/html2text.py
@@ -8,7 +8,7 @@ def html2text(html):
from html2text import HTML2Text
import re
if isinstance(html, bytes):
- from calibre.ebooks.chardet import xml_to_unicode
+ from ebook_converter.ebooks.chardet import xml_to_unicode
html = xml_to_unicode(html, strip_encoding_pats=True, resolve_entities=True)[0]
# replace tags with as becomes emphasis in html2text
html = re.sub(
diff --git a/ebook_converter/utils/icu.py b/ebook_converter/utils/icu.py
index 2dd15c0..3cac366 100644
--- a/ebook_converter/utils/icu.py
+++ b/ebook_converter/utils/icu.py
@@ -7,16 +7,17 @@ __copyright__ = '2010, Kovid Goyal '
__docformat__ = 'restructuredtext en'
import sys
-from polyglot.builtins import filter
+import unicodedata
+from ebook_converter.polyglot.builtins import filter
is_narrow_build = sys.maxunicode < 0x10ffff
# Setup code {{{
import codecs
-from calibre.constants import plugins
-from calibre.utils.config_base import tweaks
-from polyglot.builtins import unicode_type, cmp
+from ebook_converter.constants import plugins
+from ebook_converter.utils.config_base import tweaks
+from ebook_converter.polyglot.builtins import unicode_type, cmp
_locale = _collator = _primary_collator = _sort_collator = _numeric_collator = _case_sensitive_collator = None
cmp
@@ -25,44 +26,44 @@ _none = u''
_none2 = b''
_cmap = {}
-_icu, err = plugins['icu']
+_icu, err = 1, None # plugins['icu']
if _icu is None:
raise RuntimeError('Failed to load icu with error: %s' % err)
del err
-icu_unicode_version = getattr(_icu, 'unicode_version', None)
-_nmodes = {m:getattr(_icu, m) for m in ('NFC', 'NFD', 'NFKC', 'NFKD')}
+#icu_unicode_version = getattr(_icu, 'unicode_version', None)
+# _nmodes = {m:getattr(_icu, m) for m in ('NFC', 'NFD', 'NFKC', 'NFKD')}
# Ensure that the python internal filesystem and default encodings are not ASCII
-def is_ascii(name):
- try:
- return codecs.lookup(name).name == b'ascii'
- except (TypeError, LookupError):
- return True
-
-
-try:
- if is_ascii(sys.getdefaultencoding()):
- _icu.set_default_encoding(b'utf-8')
-except:
- import traceback
- traceback.print_exc()
-
-try:
- if is_ascii(sys.getfilesystemencoding()):
- _icu.set_filesystem_encoding(b'utf-8')
-except:
- import traceback
- traceback.print_exc()
-del is_ascii
+#def is_ascii(name):
+# try:
+# return codecs.lookup(name).name == b'ascii'
+# except (TypeError, LookupError):
+# return True
+#
+#
+#try:
+# if is_ascii(sys.getdefaultencoding()):
+# _icu.set_default_encoding(b'utf-8')
+#except:
+# import traceback
+# traceback.print_exc()
+#
+#try:
+# if is_ascii(sys.getfilesystemencoding()):
+# _icu.set_filesystem_encoding(b'utf-8')
+#except:
+# import traceback
+# traceback.print_exc()
+#del is_ascii
def collator():
global _collator, _locale
if _collator is None:
if _locale is None:
- from calibre.utils.localization import get_lang
+ from ebook_converter.utils.localization import get_lang
if tweaks['locale_for_sorting']:
_locale = tweaks['locale_for_sorting']
else:
@@ -248,9 +249,9 @@ startswith = _make_func(_strcmp_template, 'startswith', collator='_collator', co
primary_startswith = _make_func(_strcmp_template, 'primary_startswith', collator='_primary_collator', collator_func='primary_collator', func='startswith')
-safe_chr = _icu.chr
+safe_chr = chr # _icu.chr
-ord_string = _icu.ord_string
+ord_string = str # _icu.ord_string
def character_name(string):
@@ -272,7 +273,8 @@ def normalize(text, mode='NFC'):
# that unless you have very good reasons not too. Also, it's speed
# decreases on wide python builds, where conversion to/from ICU's string
# representation is slower.
- return _icu.normalize(_nmodes[mode], unicode_type(text))
+ # return _icu.normalize(_nmodes[mode], unicode_type(text))
+ return unicode.normalize(mode, unicode_type(text))
def contractions(col=None):
@@ -311,13 +313,13 @@ def partition_by_first_letter(items, reverse=False, key=lambda x:x):
# Return the number of unicode codepoints in a string
-string_length = _icu.string_length if is_narrow_build else len
+string_length = len #_icu.string_length if is_narrow_build else len
# Return the number of UTF-16 codepoints in a string
-utf16_length = len if is_narrow_build else _icu.utf16_length
+utf16_length = len # if is_narrow_build else _icu.utf16_length
################################################################################
-if __name__ == '__main__':
- from calibre.utils.icu_test import run
- run(verbosity=4)
+# if __name__ == '__main__':
+ # from ebook_converter.utils.icu_test import run
+ # run(verbosity=4)
diff --git a/ebook_converter/utils/img.py b/ebook_converter/utils/img.py
index e6f14e3..28a7646 100644
--- a/ebook_converter/utils/img.py
+++ b/ebook_converter/utils/img.py
@@ -13,21 +13,21 @@ from io import BytesIO
from threading import Thread
# We use explicit module imports so tracebacks when importing are more useful
-from PyQt5.QtCore import QBuffer, QByteArray, Qt
-from PyQt5.QtGui import QColor, QImage, QImageReader, QImageWriter, QPixmap, QTransform
+#from PyQt5.QtCore import QBuffer, QByteArray, Qt
+#from PyQt5.QtGui import QColor, QImage, QImageReader, QImageWriter, QPixmap, QTransform
-from calibre import fit_image, force_unicode
-from calibre.constants import iswindows, plugins, ispy3
-from calibre.ptempfile import TemporaryDirectory
-from calibre.utils.config_base import tweaks
-from calibre.utils.filenames import atomic_rename
-from calibre.utils.imghdr import what
-from polyglot.builtins import string_or_bytes, unicode_type
+from ebook_converter import fit_image, force_unicode
+from ebook_converter.constants import iswindows, plugins, ispy3
+from ebook_converter.ptempfile import TemporaryDirectory
+from ebook_converter.utils.config_base import tweaks
+from ebook_converter.utils.filenames import atomic_rename
+from ebook_converter.utils.imghdr import what
+from ebook_converter.polyglot.builtins import string_or_bytes, unicode_type
# Utilities {{{
-imageops, imageops_err = plugins['imageops']
-if imageops is None:
- raise RuntimeError(imageops_err)
+# imageops, imageops_err = plugins['imageops']
+# if imageops is None:
+ # raise RuntimeError(imageops_err)
class NotImage(ValueError):
@@ -42,7 +42,7 @@ def normalize_format_name(fmt):
def get_exe_path(name):
- from calibre.ebooks.pdf.pdftohtml import PDFTOHTML
+ from ebook_converter.ebooks.pdf.pdftohtml import PDFTOHTML
base = os.path.dirname(PDFTOHTML)
if iswindows:
name += '-calibre.exe'
@@ -609,7 +609,7 @@ def optimize_png(file_path, level=7):
def encode_jpeg(file_path, quality=80):
- from calibre.utils.speedups import ReadOnlyFileBuffer
+ from ebook_converter.utils.speedups import ReadOnlyFileBuffer
quality = max(0, min(100, int(quality)))
exe = get_exe_path('cjpeg')
cmd = [exe] + '-optimize -progressive -maxmemory 100M -quality'.split() + [unicode_type(quality)]
@@ -626,8 +626,8 @@ def encode_jpeg(file_path, quality=80):
def test(): # {{{
- from calibre.ptempfile import TemporaryDirectory
- from calibre import CurrentDir
+ from ebook_converter.ptempfile import TemporaryDirectory
+ from ebook_converter import CurrentDir
from glob import glob
img = image_from_data(I('lt.png', data=True, allow_user_override=False))
with TemporaryDirectory() as tdir, CurrentDir(tdir):
diff --git a/ebook_converter/utils/imghdr.py b/ebook_converter/utils/imghdr.py
index fa6558d..3774c64 100644
--- a/ebook_converter/utils/imghdr.py
+++ b/ebook_converter/utils/imghdr.py
@@ -5,9 +5,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from struct import unpack, error
import os
-from calibre.utils.speedups import ReadOnlyFileBuffer
-from calibre.constants import ispy3
-from polyglot.builtins import string_or_bytes, unicode_type
+from ebook_converter.utils.speedups import ReadOnlyFileBuffer
+from ebook_converter.constants import ispy3
+from ebook_converter.polyglot.builtins import string_or_bytes, unicode_type
""" Recognize image file formats and sizes based on their first few bytes."""
diff --git a/ebook_converter/utils/ipc/__init__.py b/ebook_converter/utils/ipc/__init__.py
index b2a8aaf..6e35132 100644
--- a/ebook_converter/utils/ipc/__init__.py
+++ b/ebook_converter/utils/ipc/__init__.py
@@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
import os, errno, sys
from threading import Thread
-from calibre import force_unicode
-from calibre.constants import iswindows, get_windows_username, islinux, filesystem_encoding, ispy3
-from calibre.utils.filenames import ascii_filename
-from polyglot.functools import lru_cache
+from ebook_converter import force_unicode
+from ebook_converter.constants import iswindows, get_windows_username, islinux, filesystem_encoding, ispy3
+from ebook_converter.utils.filenames import ascii_filename
+from ebook_converter.polyglot.functools import lru_cache
VADDRESS = None
diff --git a/ebook_converter/utils/ipc/launch.py b/ebook_converter/utils/ipc/launch.py
index fddfae7..94354ae 100644
--- a/ebook_converter/utils/ipc/launch.py
+++ b/ebook_converter/utils/ipc/launch.py
@@ -9,12 +9,12 @@ __docformat__ = 'restructuredtext en'
import subprocess, os, sys, time
from functools import partial
-from calibre.constants import iswindows, isosx, isfrozen, filesystem_encoding, ispy3
-from calibre.utils.config import prefs
-from calibre.ptempfile import PersistentTemporaryFile, base_dir
-from calibre.utils.serialize import msgpack_dumps
-from polyglot.builtins import iteritems, unicode_type, string_or_bytes, environ_item, native_string_type, getcwd
-from polyglot.binary import as_hex_unicode
+from ebook_converter.constants import iswindows, isosx, isfrozen, filesystem_encoding, ispy3
+from ebook_converter.utils.config import prefs
+from ebook_converter.ptempfile import PersistentTemporaryFile, base_dir
+from ebook_converter.utils.serialize import msgpack_dumps
+from ebook_converter.polyglot.builtins import iteritems, unicode_type, string_or_bytes, environ_item, native_string_type, getcwd
+from ebook_converter.polyglot.binary import as_hex_unicode
if iswindows:
import win32process
diff --git a/ebook_converter/utils/ipc/simple_worker.py b/ebook_converter/utils/ipc/simple_worker.py
index 32b173c..0a6cb83 100644
--- a/ebook_converter/utils/ipc/simple_worker.py
+++ b/ebook_converter/utils/ipc/simple_worker.py
@@ -11,13 +11,13 @@ from multiprocessing.connection import Client
from threading import Thread
from contextlib import closing
-from calibre.constants import iswindows
-from calibre.utils.ipc import eintr_retry_call
-from calibre.utils.ipc.launch import Worker
-from calibre.utils.serialize import msgpack_loads, msgpack_dumps
-from calibre.utils.monotonic import monotonic
-from polyglot.builtins import unicode_type, string_or_bytes, environ_item
-from polyglot.binary import as_hex_unicode, from_hex_bytes
+from ebook_converter.constants import iswindows
+from ebook_converter.utils.ipc import eintr_retry_call
+from ebook_converter.utils.ipc.launch import Worker
+from ebook_converter.utils.serialize import msgpack_loads, msgpack_dumps
+from ebook_converter.utils.monotonic import monotonic
+from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, environ_item
+from ebook_converter.polyglot.binary import as_hex_unicode, from_hex_bytes
class WorkerError(Exception):
@@ -125,7 +125,7 @@ def communicate(ans, worker, listener, args, timeout=300, heartbeat=None,
def create_worker(env, priority='normal', cwd=None, func='main'):
- from calibre.utils.ipc.server import create_listener
+ from ebook_converter.utils.ipc.server import create_listener
auth_key = os.urandom(32)
address, listener = create_listener(auth_key)
@@ -133,7 +133,7 @@ def create_worker(env, priority='normal', cwd=None, func='main'):
env.update({
'CALIBRE_WORKER_ADDRESS': environ_item(as_hex_unicode(msgpack_dumps(address))),
'CALIBRE_WORKER_KEY': environ_item(as_hex_unicode(auth_key)),
- 'CALIBRE_SIMPLE_WORKER': environ_item('calibre.utils.ipc.simple_worker:%s' % func),
+ 'CALIBRE_SIMPLE_WORKER': environ_item('ebook_converter.utils.ipc.simple_worker:%s' % func),
})
w = Worker(env)
@@ -295,14 +295,14 @@ def main():
try:
mod, func, args, kwargs, module_is_source_code = args
if module_is_source_code:
- importlib.import_module('calibre.customize.ui') # Load plugins
+ importlib.import_module('ebook_converter.customize.ui') # Load plugins
mod = compile_code(mod)
func = mod[func]
else:
try:
mod = importlib.import_module(mod)
except ImportError:
- importlib.import_module('calibre.customize.ui') # Load plugins
+ importlib.import_module('ebook_converter.customize.ui') # Load plugins
mod = importlib.import_module(mod)
func = getattr(mod, func)
res = {'result':func(*args, **kwargs)}
@@ -337,7 +337,7 @@ def offload():
try:
m = importlib.import_module(mod)
except ImportError:
- importlib.import_module('calibre.customize.ui') # Load plugins
+ importlib.import_module('ebook_converter.customize.ui') # Load plugins
m = importlib.import_module(mod)
func_cache[(mod, func)] = f = getattr(m, func)
res['result'] = f(*args, **kwargs)
diff --git a/ebook_converter/utils/iso8601.py b/ebook_converter/utils/iso8601.py
index eb4ffec..2b52fbd 100644
--- a/ebook_converter/utils/iso8601.py
+++ b/ebook_converter/utils/iso8601.py
@@ -7,10 +7,10 @@ from datetime import datetime
from dateutil.tz import tzlocal, tzutc, tzoffset
-from calibre.constants import plugins
-speedup, err = plugins['speedup']
-if not speedup:
- raise RuntimeError(err)
+from ebook_converter.constants import plugins
+# speedup, err = plugins['speedup']
+# if not speedup:
+ # raise RuntimeError(err)
class SafeLocalTimeZone(tzlocal):
diff --git a/ebook_converter/utils/localization.py b/ebook_converter/utils/localization.py
index 6228e4f..3f2de4c 100644
--- a/ebook_converter/utils/localization.py
+++ b/ebook_converter/utils/localization.py
@@ -1,7 +1,3 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
@@ -9,7 +5,7 @@ __docformat__ = 'restructuredtext en'
import os, locale, re, io, sys
from gettext import GNUTranslations, NullTranslations
-from polyglot.builtins import is_py3, iteritems, unicode_type
+from ebook_converter.polyglot.builtins import is_py3, iteritems, unicode_type
_available_translations = None
@@ -19,7 +15,7 @@ def available_translations():
if _available_translations is None:
stats = P('localization/stats.calibre_msgpack', allow_user_override=False)
if os.path.exists(stats):
- from calibre.utils.serialize import msgpack_loads
+ from ebook_converter.utils.serialize import msgpack_loads
with open(stats, 'rb') as f:
stats = msgpack_loads(f.read())
else:
@@ -29,11 +25,11 @@ def available_translations():
def get_system_locale():
- from calibre.constants import iswindows, isosx, plugins
+ from ebook_converter.constants import iswindows, isosx, plugins
lang = None
if iswindows:
try:
- from calibre.constants import get_windows_user_locale_name
+ from ebook_converter.constants import get_windows_user_locale_name
lang = get_windows_user_locale_name()
lang = lang.strip()
if not lang:
@@ -86,7 +82,7 @@ def sanitize_lang(lang):
def get_lang():
'Try to figure out what language to display the interface in'
- from calibre.utils.config_base import prefs
+ from ebook_converter.utils.config_base import prefs
lang = prefs['language']
lang = os.environ.get('CALIBRE_OVERRIDE_LANG', lang)
if lang:
@@ -197,7 +193,7 @@ lcdata = {
def load_po(path):
- from calibre.translations.msgfmt import make
+ from ebook_converter.translations.msgfmt import make
buf = io.BytesIO()
try:
make(path, buf)
@@ -238,7 +234,7 @@ def set_translators():
except:
pass # No iso639 translations for this lang
if buf is not None:
- from calibre.utils.serialize import msgpack_loads
+ from ebook_converter.utils.serialize import msgpack_loads
try:
lcdata = msgpack_loads(zf.read(mpath + '/lcdata.calibre_msgpack'))
except:
@@ -264,7 +260,7 @@ def set_translators():
# Now that we have installed a translator, we have to retranslate the help
# for the global prefs object as it was instantiated in get_lang(), before
# the translator was installed.
- from calibre.utils.config_base import prefs
+ from ebook_converter.utils.config_base import prefs
prefs.retranslate_help()
@@ -367,7 +363,7 @@ def _load_iso639():
global _iso639
if _iso639 is None:
ip = P('localization/iso639.calibre_msgpack', allow_user_override=False, data=True)
- from calibre.utils.serialize import msgpack_loads
+ from ebook_converter.utils.serialize import msgpack_loads
_iso639 = msgpack_loads(ip)
if 'by_3' not in _iso639:
_iso639['by_3'] = _iso639['by_3t']
@@ -491,7 +487,7 @@ _udc = None
def get_udc():
global _udc
if _udc is None:
- from calibre.ebooks.unihandecode import Unihandecoder
+ from ebook_converter.ebooks.unihandecode import Unihandecoder
_udc = Unihandecoder(lang=get_lang())
return _udc
@@ -509,19 +505,19 @@ def user_manual_stats():
def localize_user_manual_link(url):
- lc = lang_as_iso639_1(get_lang())
- if lc == 'en':
- return url
- stats = user_manual_stats()
- if stats.get(lc, 0) < 0.3:
- return url
- from polyglot.urllib import urlparse, urlunparse
- parts = urlparse(url)
- path = re.sub(r'/generated/[a-z]+/', '/generated/%s/' % lc, parts.path or '')
- path = '/%s%s' % (lc, path)
- parts = list(parts)
- parts[2] = path
- return urlunparse(parts)
+ #lc = lang_as_iso639_1(get_lang())
+ # if lc == 'en':
+ return url
+ # stats = user_manual_stats()
+ # if stats.get(lc, 0) < 0.3:
+ # return url
+ # from polyglot.urllib import urlparse, urlunparse
+ # parts = urlparse(url)
+ # path = re.sub(r'/generated/[a-z]+/', '/generated/%s/' % lc, parts.path or '')
+ # path = '/%s%s' % (lc, path)
+ # parts = list(parts)
+ # parts[2] = path
+ # return urlunparse(parts)
def website_languages():
@@ -540,7 +536,7 @@ def localize_website_link(url):
langs = website_languages()
if lc == 'en' or lc not in langs:
return url
- from polyglot.urllib import urlparse, urlunparse
+ from ebook_converter.polyglot.urllib import urlparse, urlunparse
parts = urlparse(url)
path = '/{}{}'.format(lc, parts.path)
parts = list(parts)
diff --git a/ebook_converter/utils/localunzip.py b/ebook_converter/utils/localunzip.py
index b0d0ab5..2aaa74e 100644
--- a/ebook_converter/utils/localunzip.py
+++ b/ebook_converter/utils/localunzip.py
@@ -18,7 +18,7 @@ from struct import calcsize, unpack, pack
from collections import namedtuple, OrderedDict
from tempfile import SpooledTemporaryFile
-from polyglot.builtins import itervalues, getcwd
+from ebook_converter.polyglot.builtins import itervalues, getcwd
HEADER_SIG = 0x04034b50
HEADER_BYTE_SIG = pack(b'
-from __future__ import absolute_import, division, print_function, unicode_literals
-
import atexit
import errno
import os
@@ -12,15 +8,15 @@ import tempfile
import time
from functools import partial
-from calibre.constants import (
+from ebook_converter.constants import (
__appname__, fcntl, filesystem_encoding, islinux, isosx, iswindows, plugins, ispy3
)
-from calibre.utils.monotonic import monotonic
+from ebook_converter.utils.monotonic import monotonic
-speedup = plugins['speedup'][0]
+# speedup = plugins['speedup'][0]
if iswindows:
import msvcrt, win32file, pywintypes, winerror, win32api, win32event
- from calibre.constants import get_windows_username
+ from ebook_converter.constants import get_windows_username
excl_file_mode = stat.S_IREAD | stat.S_IWRITE
else:
excl_file_mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
@@ -29,14 +25,14 @@ else:
def unix_open(path):
flags = os.O_RDWR | os.O_CREAT
has_cloexec = False
- if hasattr(speedup, 'O_CLOEXEC'):
- try:
- fd = os.open(path, flags | speedup.O_CLOEXEC, excl_file_mode)
- has_cloexec = True
- except EnvironmentError as err:
- # Kernel may not support O_CLOEXEC
- if err.errno != errno.EINVAL:
- raise
+ #if hasattr(speedup, 'O_CLOEXEC'):
+ # try:
+ # fd = os.open(path, flags | speedup.O_CLOEXEC, excl_file_mode)
+ # has_cloexec = True
+ # except EnvironmentError as err:
+ # # Kernel may not support O_CLOEXEC
+ # if err.errno != errno.EINVAL:
+ # raise
if not has_cloexec:
fd = os.open(path, flags, excl_file_mode)
@@ -85,7 +81,7 @@ def retry_for_a_time(timeout, sleep_time, func, error_retry, *args):
time.sleep(sleep_time)
-def lock_file(path, timeout=15, sleep_time=0.2):
+def _lock_file(path, timeout=15, sleep_time=0.2):
if iswindows:
return retry_for_a_time(
timeout, sleep_time, windows_open, windows_retry, path
@@ -98,6 +94,13 @@ def lock_file(path, timeout=15, sleep_time=0.2):
return f
+def lock_file(path, timeout=15, sleep_time=0.2):
+ from filelock import FileLock
+ lock = FileLock(path + '.lock', timeout=timeout)
+ with lock:
+ return unix_open(path)
+
+
class ExclusiveFile(object):
def __init__(self, path, timeout=15, sleep_time=0.2):
@@ -147,7 +150,7 @@ elif islinux:
def create_single_instance_mutex(name, per_user=True):
import socket
- from calibre.utils.ipc import eintr_retry_call
+ from ebook_converter.utils.ipc import eintr_retry_call
name = '%s-singleinstance-%s-%s' % (
__appname__, (os.geteuid() if per_user else ''), name
)
@@ -185,7 +188,7 @@ else:
)
def create_single_instance_mutex(name, per_user=True):
- from calibre.utils.ipc import eintr_retry_call
+ from ebook_converter.utils.ipc import eintr_retry_call
path = singleinstance_path(name, per_user)
f = lopen(path, 'w')
try:
diff --git a/ebook_converter/utils/logging.py b/ebook_converter/utils/logging.py
index 1f8a5d7..0e5cc53 100644
--- a/ebook_converter/utils/logging.py
+++ b/ebook_converter/utils/logging.py
@@ -14,8 +14,8 @@ import sys, traceback, io
from functools import partial
from threading import Lock
-from calibre import isbytestring, force_unicode, as_unicode, prints
-from polyglot.builtins import unicode_type, iteritems
+from ebook_converter import isbytestring, force_unicode, as_unicode, prints
+from ebook_converter.polyglot.builtins import unicode_type, iteritems
class Stream(object):
@@ -45,7 +45,7 @@ class ANSIStream(Stream):
}
def prints(self, level, *args, **kwargs):
- from calibre.utils.terminal import ColoredStream
+ from ebook_converter.utils.terminal import ColoredStream
with ColoredStream(self.stream, self.color[level]):
self._prints(*args, **kwargs)
diff --git a/ebook_converter/utils/resources.py b/ebook_converter/utils/resources.py
index f63b884..797d55d 100644
--- a/ebook_converter/utils/resources.py
+++ b/ebook_converter/utils/resources.py
@@ -1,7 +1,3 @@
-#!/usr/bin/env python2
-# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
-from __future__ import absolute_import, division, print_function, unicode_literals
-
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
@@ -9,8 +5,8 @@ __docformat__ = 'restructuredtext en'
import sys, os
-from calibre import config_dir
-from polyglot.builtins import builtins
+from ebook_converter import config_dir
+from ebook_converter.polyglot.builtins import builtins
user_dir = os.path.join(config_dir, 'resources')
@@ -19,6 +15,7 @@ user_dir = os.path.join(config_dir, 'resources')
class PathResolver(object):
def __init__(self):
+ sys.resources_location = os.path.abspath(os.path.dirname(__file__))
self.locations = [sys.resources_location]
self.cache = {}
@@ -86,6 +83,7 @@ _resolver = PathResolver()
def get_path(path, data=False, allow_user_override=True):
fpath = _resolver(path, allow_user_override=allow_user_override)
+
if data:
with open(fpath, 'rb') as f:
return f.read()
diff --git a/ebook_converter/utils/serialize.py b/ebook_converter/utils/serialize.py
index f5d560c..7cbc30c 100644
--- a/ebook_converter/utils/serialize.py
+++ b/ebook_converter/utils/serialize.py
@@ -4,8 +4,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals
-from polyglot.builtins import unicode_type
-from calibre.constants import ispy3
+from ebook_converter.polyglot.builtins import unicode_type
+from ebook_converter.constants import ispy3
MSGPACK_MIME = 'application/x-msgpack'
@@ -31,11 +31,11 @@ def create_encoder(for_json=False):
if isinstance(obj, (set, frozenset)):
return encoded(1, tuple(obj), ExtType)
if getattr(obj, '__calibre_serializable__', False):
- from calibre.ebooks.metadata.book.base import Metadata
- from calibre.library.field_metadata import FieldMetadata, fm_as_dict
- from calibre.db.categories import Tag
+ from ebook_converter.ebooks.metadata.book.base import Metadata
+ from ebook_converter.library.field_metadata import FieldMetadata, fm_as_dict
+ from ebook_converter.db.categories import Tag
if isinstance(obj, Metadata):
- from calibre.ebooks.metadata.book.serialize import metadata_as_dict
+ from ebook_converter.ebooks.metadata.book.serialize import metadata_as_dict
return encoded(
2, metadata_as_dict(obj, encode_cover_data=for_json), ExtType
)
@@ -66,8 +66,8 @@ def json_dumps(data, **kw):
def decode_metadata(x, for_json):
- from polyglot.binary import from_base64_bytes
- from calibre.ebooks.metadata.book.serialize import metadata_from_dict
+ from ebook_converter.polyglot.binary import from_base64_bytes
+ from ebook_converter.ebooks.metadata.book.serialize import metadata_from_dict
obj = metadata_from_dict(x)
if for_json and obj.cover_data and obj.cover_data[1]:
obj.cover_data = obj.cover_data[0], from_base64_bytes(obj.cover_data[1])
@@ -75,17 +75,17 @@ def decode_metadata(x, for_json):
def decode_field_metadata(x, for_json):
- from calibre.library.field_metadata import fm_from_dict
+ from ebook_converter.library.field_metadata import fm_from_dict
return fm_from_dict(x)
def decode_category_tag(x, for_json):
- from calibre.db.categories import Tag
+ from ebook_converter.db.categories import Tag
return Tag.from_dict(x)
def decode_datetime(x, fj):
- from calibre.utils.iso8601 import parse_iso8601
+ from ebook_converter.utils.iso8601 import parse_iso8601
return parse_iso8601(x, assume_utc=True)
diff --git a/ebook_converter/utils/shared_file.py b/ebook_converter/utils/shared_file.py
index 836c225..ac6fecd 100644
--- a/ebook_converter/utils/shared_file.py
+++ b/ebook_converter/utils/shared_file.py
@@ -7,9 +7,9 @@ __copyright__ = '2015, Kovid Goyal '
import os, sys
-from polyglot.builtins import reraise
+from ebook_converter.polyglot.builtins import reraise
-from calibre.constants import iswindows, plugins, ispy3
+from ebook_converter.constants import iswindows, plugins, ispy3
'''
This module defines a share_open() function which is a replacement for
@@ -28,10 +28,10 @@ directory until all file handles are closed. To get around this, rename the
file before deleting it.
'''
-speedup, err = plugins['speedup']
+# speedup, err = plugins['speedup']
-if not speedup:
- raise RuntimeError('Failed to load the speedup plugin with error: %s' % err)
+# if not speedup:
+ # raise RuntimeError('Failed to load the speedup plugin with error: %s' % err)
valid_modes = {'a', 'a+', 'a+b', 'ab', 'r', 'rb', 'r+', 'r+b', 'w', 'wb', 'w+', 'w+b'}
@@ -81,117 +81,12 @@ def flags_from_mode(mode):
return flags
-if iswindows:
- from numbers import Integral
- import msvcrt
- import win32file, pywintypes
- CREATE_NEW = win32file.CREATE_NEW
- CREATE_ALWAYS = win32file.CREATE_ALWAYS
- OPEN_EXISTING = win32file.OPEN_EXISTING
- OPEN_ALWAYS = win32file.OPEN_ALWAYS
- TRUNCATE_EXISTING = win32file.TRUNCATE_EXISTING
- FILE_SHARE_READ = win32file.FILE_SHARE_READ
- FILE_SHARE_WRITE = win32file.FILE_SHARE_WRITE
- FILE_SHARE_DELETE = win32file.FILE_SHARE_DELETE
- FILE_SHARE_VALID_FLAGS = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
- FILE_ATTRIBUTE_READONLY = win32file.FILE_ATTRIBUTE_READONLY
- FILE_ATTRIBUTE_NORMAL = win32file.FILE_ATTRIBUTE_NORMAL
- FILE_ATTRIBUTE_TEMPORARY = win32file.FILE_ATTRIBUTE_TEMPORARY
- FILE_FLAG_DELETE_ON_CLOSE = win32file.FILE_FLAG_DELETE_ON_CLOSE
- FILE_FLAG_SEQUENTIAL_SCAN = win32file.FILE_FLAG_SEQUENTIAL_SCAN
- FILE_FLAG_RANDOM_ACCESS = win32file.FILE_FLAG_RANDOM_ACCESS
- GENERIC_READ = win32file.GENERIC_READ & 0xffffffff
- GENERIC_WRITE = win32file.GENERIC_WRITE & 0xffffffff
- DELETE = 0x00010000
-
- _ACCESS_MASK = os.O_RDONLY | os.O_WRONLY | os.O_RDWR
- _ACCESS_MAP = {
- os.O_RDONLY : GENERIC_READ,
- os.O_WRONLY : GENERIC_WRITE,
- os.O_RDWR : GENERIC_READ | GENERIC_WRITE
- }
-
- _CREATE_MASK = os.O_CREAT | os.O_EXCL | os.O_TRUNC
- _CREATE_MAP = {
- 0 : OPEN_EXISTING,
- os.O_EXCL : OPEN_EXISTING,
- os.O_CREAT : OPEN_ALWAYS,
- os.O_CREAT | os.O_EXCL : CREATE_NEW,
- os.O_CREAT | os.O_TRUNC | os.O_EXCL : CREATE_NEW,
- os.O_TRUNC : TRUNCATE_EXISTING,
- os.O_TRUNC | os.O_EXCL : TRUNCATE_EXISTING,
- os.O_CREAT | os.O_TRUNC : CREATE_ALWAYS
- }
-
- def raise_winerror(pywinerr):
- reraise(
- WindowsError,
- WindowsError(pywinerr.winerror,
- (pywinerr.funcname or '') + b': ' + (pywinerr.strerror or '')),
- sys.exc_info()[2])
-
- def os_open(path, flags, mode=0o777, share_flags=FILE_SHARE_VALID_FLAGS):
- '''
- Replacement for os.open() allowing moving or unlinking before closing
- '''
- if not isinstance(flags, Integral):
- raise TypeError('flags must be an integer')
- if not isinstance(mode, Integral):
- raise TypeError('mode must be an integer')
-
- if share_flags & ~FILE_SHARE_VALID_FLAGS:
- raise ValueError('bad share_flags: %r' % share_flags)
-
- access_flags = _ACCESS_MAP[flags & _ACCESS_MASK]
- create_flags = _CREATE_MAP[flags & _CREATE_MASK]
- attrib_flags = FILE_ATTRIBUTE_NORMAL
-
- if flags & os.O_CREAT and mode & ~0o444 == 0:
- attrib_flags = FILE_ATTRIBUTE_READONLY
-
- if flags & os.O_TEMPORARY:
- share_flags |= FILE_SHARE_DELETE
- attrib_flags |= FILE_FLAG_DELETE_ON_CLOSE
- access_flags |= DELETE
-
- if flags & os.O_SHORT_LIVED:
- attrib_flags |= FILE_ATTRIBUTE_TEMPORARY
-
- if flags & os.O_SEQUENTIAL:
- attrib_flags |= FILE_FLAG_SEQUENTIAL_SCAN
-
- if flags & os.O_RANDOM:
- attrib_flags |= FILE_FLAG_RANDOM_ACCESS
-
- try:
- h = win32file.CreateFileW(
- path, access_flags, share_flags, None, create_flags, attrib_flags, None)
- except pywintypes.error as e:
- raise_winerror(e)
- ans = msvcrt.open_osfhandle(h, flags | os.O_NOINHERIT)
- h.Detach() # We dont want the handle to be automatically closed when h is deleted
- return ans
-
- def share_open(path, mode='r', buffering=-1):
- flags = flags_from_mode(mode)
- return speedup.fdopen(os_open(path, flags), path, mode, buffering)
-
-else:
- if ispy3:
- # See PEP 446
- share_open = open
- else:
- def share_open(path, mode='r', buffering=-1):
- flags = flags_from_mode(mode) | speedup.O_CLOEXEC
- return speedup.fdopen(os.open(path, flags), path, mode, buffering)
-
- def raise_winerror(x):
- reraise(NotImplementedError, None, sys.exc_info()[2])
+share_open = open
def find_tests():
import unittest
- from calibre.ptempfile import TemporaryDirectory
+ from ebook_converter.ptempfile import TemporaryDirectory
class SharedFileTest(unittest.TestCase):
diff --git a/ebook_converter/utils/short_uuid.py b/ebook_converter/utils/short_uuid.py
index 0d8b40c..efe1a50 100644
--- a/ebook_converter/utils/short_uuid.py
+++ b/ebook_converter/utils/short_uuid.py
@@ -9,7 +9,7 @@ Generate UUID encoded using a user specified alphabet.
import string, math, uuid as _uuid
-from polyglot.builtins import unicode_type
+from ebook_converter.polyglot.builtins import unicode_type
def num_to_string(number, alphabet, alphabet_len, pad_to_length=None):
diff --git a/ebook_converter/utils/speedups.py b/ebook_converter/utils/speedups.py
index e6d5acb..6121f9e 100644
--- a/ebook_converter/utils/speedups.py
+++ b/ebook_converter/utils/speedups.py
@@ -5,7 +5,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import os
-from polyglot.builtins import range, unicode_type
+from ebook_converter.polyglot.builtins import range, unicode_type
class ReadOnlyFileBuffer(object):
diff --git a/ebook_converter/utils/terminal.py b/ebook_converter/utils/terminal.py
index a436ef0..62ff25c 100644
--- a/ebook_converter/utils/terminal.py
+++ b/ebook_converter/utils/terminal.py
@@ -8,8 +8,8 @@ __docformat__ = 'restructuredtext en'
import os, sys, re
-from calibre.constants import iswindows, ispy3
-from polyglot.builtins import iteritems, range, zip, native_string_type
+from ebook_converter.constants import iswindows, ispy3
+from ebook_converter.polyglot.builtins import iteritems, range, zip, native_string_type
if iswindows:
import ctypes.wintypes
@@ -174,7 +174,7 @@ class Detect(object):
# message and the asciized version of the text.
print('Non-ASCII text detected. You must set your Console\'s font to'
' Lucida Console or Consolas or some other TrueType font to see this text', file=self.stream, end=' -- ')
- from calibre.utils.filenames import ascii_text
+ from ebook_converter.utils.filenames import ascii_text
print(ascii_text(t + text), file=self.stream, end='')
continue
if not ignore_errors:
diff --git a/ebook_converter/utils/titlecase.py b/ebook_converter/utils/titlecase.py
index 2450e37..46cea9b 100644
--- a/ebook_converter/utils/titlecase.py
+++ b/ebook_converter/utils/titlecase.py
@@ -11,8 +11,8 @@ License: http://www.opensource.org/licenses/mit-license.php
import re
-from calibre.utils.icu import capitalize, upper
-from polyglot.builtins import unicode_type
+from ebook_converter.utils.icu import capitalize, upper
+from ebook_converter.polyglot.builtins import unicode_type
__all__ = ['titlecase']
__version__ = '0.5'
@@ -37,7 +37,7 @@ _lang = None
def lang():
global _lang
if _lang is None:
- from calibre.utils.localization import get_lang
+ from ebook_converter.utils.localization import get_lang
_lang = get_lang().lower()
return _lang
diff --git a/ebook_converter/utils/xml_parse.py b/ebook_converter/utils/xml_parse.py
index aff73a6..9e20af7 100644
--- a/ebook_converter/utils/xml_parse.py
+++ b/ebook_converter/utils/xml_parse.py
@@ -63,5 +63,5 @@ def find_tests():
if __name__ == '__main__':
- from calibre.utils.run_tests import run_tests
+ from ebook_converter.utils.run_tests import run_tests
run_tests(find_tests)
diff --git a/ebook_converter/utils/zipfile.py b/ebook_converter/utils/zipfile.py
index 93034cb..e953665 100644
--- a/ebook_converter/utils/zipfile.py
+++ b/ebook_converter/utils/zipfile.py
@@ -8,10 +8,10 @@ import binascii
from contextlib import closing
from tempfile import SpooledTemporaryFile
-from calibre import sanitize_file_name
-from calibre.constants import filesystem_encoding
-from calibre.ebooks.chardet import detect
-from polyglot.builtins import unicode_type, string_or_bytes, getcwd, map, as_bytes
+from ebook_converter import sanitize_file_name
+from ebook_converter.constants import filesystem_encoding
+from ebook_converter.ebooks.chardet import detect
+from ebook_converter.polyglot.builtins import unicode_type, string_or_bytes, getcwd, map, as_bytes
try:
import zlib # We may need its compression method
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..c39a63f
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,39 @@
+[metadata]
+name = ebook-converter
+version = 4.9.1
+summary = Convert ebook between different formats
+description-file =
+ README.rst
+author = gryf
+author-email = gryf73@gmail.com
+license = GPL3
+license_file = LICENSE
+url = https://github.com/gryf/ebook-converter
+classifier =
+ Environment :: Console
+ Intended Audience :: Other Audience
+ License :: OSI Approved :: GNU General Public License v3 (GPLv3)
+ Operating System :: POSIX :: Linux
+ Programming Language :: Python
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3 :: Only
+ Programming Language :: Python :: 3.6
+ Programming Language :: Python :: 3.7
+
+[options]
+packages = find:
+install_requires =
+ filelock
+ python-dateutil
+ lxml
+ css-parser
+ beautifulsoup4
+ tinycss
+ pillow
+ msgpack
+ html5-parser
+ odfpy
+
+[options.entry_points]
+console_scripts =
+ ebook-converter=ebook_converter.main:run
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..1c88d8c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,9 @@
+import setuptools
+
+module = setuptools.Extension('ebook_converter.ebooks.compression.cPalmdoc',
+ sources=['ebook_converter/ebooks/compression/'
+ 'palmdoc.c'],
+ language='c')
+
+setuptools.setup(ext_modules=[module])
+# setuptools.setup()