1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-03-12 12:35:53 +01:00

Convert calibre modules to ebook_converter.

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

View File

@@ -7,12 +7,12 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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('\\', '/')