forked from LiveCarta/BookConverter
epub converter: rename Book class
This commit is contained in:
@@ -10,7 +10,7 @@ from threading import Event
|
||||
import pika
|
||||
|
||||
from access import Access
|
||||
from docx_converter import Book
|
||||
from docx_converter import DocxBook
|
||||
from epub_converter import EpubBook
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def configure_file_logger(name, filename='logs/converter_log.log', filemode='w+'
|
||||
return logger
|
||||
|
||||
|
||||
def convert_book(book_type: [Book, EpubBook], params: dict, logger, book_id):
|
||||
def convert_book(book_type: [DocxBook, EpubBook], params: dict, logger, book_id):
|
||||
logger.info(f'Start processing book-{book_id}.')
|
||||
|
||||
try:
|
||||
@@ -57,7 +57,7 @@ def callback(ch, method, properties, body, logger, libra_locker):
|
||||
book_params.update({'libra_locker': libra_locker})
|
||||
|
||||
params = {
|
||||
'book_type': EpubBook if data.get('fileExtension') == 'epub' else Book,
|
||||
'book_type': EpubBook if data.get('fileExtension') == 'epub' else DocxBook,
|
||||
'book_id': data['id'],
|
||||
'logger': logger,
|
||||
'params': book_params
|
||||
@@ -85,9 +85,9 @@ def local_convert_book(filename, locker):
|
||||
folder_path = os.path.dirname(os.path.dirname(os.path.abspath("__file__")))
|
||||
output_path = Path(os.path.join(folder_path, f'json/{filename}.json'))
|
||||
try:
|
||||
book = Book(book_id=filename,
|
||||
main_logger=logger,
|
||||
libra_locker=locker)
|
||||
book = DocxBook(book_id=filename,
|
||||
main_logger=logger,
|
||||
libra_locker=locker)
|
||||
book.test_conversion()
|
||||
|
||||
except Exception as exc:
|
||||
|
||||
@@ -14,7 +14,7 @@ from html_preprocessor import HTMLPreprocessor
|
||||
from json_postprocessor import JSONConverter
|
||||
|
||||
|
||||
class Book:
|
||||
class DocxBook:
|
||||
|
||||
def __init__(self, book_id=0, access=None, docx_path=None, html_path=None, output_path=None,
|
||||
main_logger=None, libra_locker=None,
|
||||
@@ -263,5 +263,5 @@ if __name__ == "__main__":
|
||||
file = pathlib.Path(os.path.join(folder, 'html/ch13/Ch_13_edit.html'))
|
||||
out_path = pathlib.Path(os.path.join(folder, 'json/ch13.json'))
|
||||
|
||||
book = Book(html_path=file, output_path=out_path)
|
||||
book = DocxBook(html_path=file, output_path=out_path)
|
||||
book.convert_from_html()
|
||||
|
||||
Reference in New Issue
Block a user