Merge pull request #314 from Teqniksoft/kiryl/converter_fix

Small folder changes
This commit is contained in:
Kiryl
2022-11-08 16:42:04 +03:00
committed by GitHub
13 changed files with 15 additions and 15 deletions

2
.gitignore vendored
View File

@@ -69,7 +69,7 @@ instance/
.scrapy
# Sphinx documentation
docs/_build/
documentation/_build/
# PyBuilder
target/

View File

@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.11.0
RUN apt-get update && \
apt-get install -y software-properties-common

View File

@@ -20,7 +20,7 @@ def local_convert_book(book_type: [DocxBook, EpubBook], book_id: int, logger: lo
try:
json_file_path = "books/json/9781614382264.json"
book = book_type(book_id=book_id, main_logger=logger, **params)
book.conversion_local(json_file_path)
book.conversion(json_file_path)
except Exception as exc:
raise exc
logger.info(f"Book-{book_id} has been proceeded.")
@@ -78,7 +78,7 @@ def server_run():
try:
folder_path = os.path.dirname(os.path.abspath(__file__))
config_path = Path(os.path.join(
folder_path, "config/queue_config.json"))
folder_path, "configs/queue_config.json"))
with open(config_path, "r") as f:
conf_param = json.load(f)
@@ -95,7 +95,7 @@ def server_run():
channel.queue_declare(queue=conf_param["queue"], durable=True, arguments={
"x-max-priority": 10})
except TypeError as exc:
print("TypeError: problem with config, " + str(exc))
print("TypeError: problem with queue config, " + str(exc))
except ValueError as exc:
logger_object.log(logging.ERROR,
f"Queue {conf_param['queue']} is not declared.")

View File

@@ -42,7 +42,7 @@ class Access:
def set_credentials(self, url: str):
folder_path: str = os.path.dirname(
os.path.dirname(os.path.abspath(__file__)))
config_path: str = os.path.join(folder_path, "config/api_config.json")
config_path: str = os.path.join(folder_path, "configs/api_config.json")
with open(config_path, "r") as f:
params: Dict[str, str] = json.load(f)

View File

@@ -77,14 +77,14 @@ class BookSolver:
"""Method for getting and saving preset from server"""
try:
pass
self.preset_path = "presets/docx_presets.json"
self.preset_path = "preset/docx_presets.json"
# self.logger_object.log(f"Start receiving preset file from server. URL:"
# f" {self.access.url}/doc-convert/{self.book_id}/presets")
# f" {self.access.url}/doc-convert/{self.book_id}/preset")
# content = self.access.get_file(
# file_path=f"{self.access.url}/doc-convert/{self.book_id}/presets")
# file_path=f"{self.access.url}/doc-convert/{self.book_id}/preset")
# self.logger_object.log("Preset file was received from server.")
# self.preset_path = pathlib.Path(
# str(self.save_file(content, path_to_save="presets", file_type="json")))
# str(self.save_file(content, path_to_save="preset", file_type="json")))
except FileNotFoundError as f_err:
self.logger_object.log(
"Can't get preset file from server.", logging.ERROR)

View File

@@ -50,7 +50,7 @@ class DocxBook(BookSolver):
# 2. Parses and cleans html, gets list of tags, gets footnotes
try:
html_preprocessor = HtmlPresetsProcessor(
logger=self.logger_object, preset_path="presets/docx_presets.json")
logger=self.logger_object, preset_path="preset/docx_presets.json")
style_preprocessor = StyleReader()
html_processor = HtmlDocxProcessor(html_soup=html_converter.html_soup,
logger=self.logger_object,
@@ -91,7 +91,7 @@ if __name__ == "__main__":
html_converter = Docx2LibreHtml(file_path=docx_file_path,
logger=logger_object, libre_locker=locker)
html_preprocessor = HtmlPresetsProcessor(
logger=logger_object, preset_path="../../presets/docx_presets.json")
logger=logger_object, preset_path="../../preset/docx_presets.json")
style_preprocessor = StyleReader()
html_processor = HtmlDocxProcessor(html_soup=html_converter.html_soup, logger=logger_object,
html_preprocessor=html_preprocessor, style_preprocessor=style_preprocessor)

View File

@@ -35,7 +35,7 @@ class EpubBook(BookSolver):
# Parses and cleans html, gets list of tags, gets footnotes
try:
html_preprocessor = HtmlPresetsProcessor(
logger=self.logger_object, preset_path="presets/epub_presets.json")
logger=self.logger_object, preset_path="preset/epub_presets.json")
html_processor = HtmlEpubProcessor(logger=self.logger_object,
html_preprocessor=html_preprocessor)
except Exception as exc:
@@ -58,7 +58,7 @@ if __name__ == "__main__":
logger_object.configure_book_logger(book_id=epub_file_path.split("/")[-1])
html_preprocessor = HtmlPresetsProcessor(
logger=logger_object, preset_path="../../presets/epub_presets.json")
logger=logger_object, preset_path="../../preset/epub_presets.json")
style_preprocessor = StyleReader()
html_processor = HtmlEpubProcessor(logger=logger_object,
html_preprocessor=html_preprocessor)

View File

@@ -20,7 +20,7 @@ def check_dir(dir_path: str):
if __name__ == "__main__":
folders = parse_args().folders
if not folders:
folders = ["books/epub", "books/docx", "books/html", "books/json", "logs", "config"]
folders = ["books/epub", "books/docx", "books/html", "books/json", "logs", "configs"]
folder_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
folders = [os.path.join(folder_path, folder) for folder in folders]