diff --git a/ci_build/build.xml b/ci_build/build.xml index 783c94d..b894f00 100644 --- a/ci_build/build.xml +++ b/ci_build/build.xml @@ -1,5 +1,5 @@ - + 1: - self.logger.log(f"Warning in {toc_href}: multiple anchors:" + self.logger.log(f"Warning in {html_href_from_toc}: multiple anchors:" f"{len(anchor_tags)} found.\n" f"{anchor_tags}\n" f"While processing {internal_link_tag}") - anchor_tag = anchor_tags[0] - assert anchor_tag.attrs["id"] in [new_id, a_tag_id] + assert anchor_tag.attrs["id"] in [new_unique_id, id_] # if anchor is found we could add placeholder for link creation on server side. - internal_link_tag.attrs["placeholder"] = "{{tempStyleToAnchor-" + new_id + "}}" + internal_link_tag.attrs["placeholder"] = "{{tempStyleToAnchor-" + new_unique_id + "}}" # create span to have cyclic links, link has 1 type of class, anchor another - if anchor_tag.attrs["id"] not in self.internal_anchors: - new_anchor_span = self.create_new_anchor_span( - soup, new_id) - anchor_tag.insert_before(new_anchor_span) - self.internal_anchors.add(new_id) - del anchor_tag.attrs["id"] + span_creation() del internal_link_tag.attrs["href"] else: internal_link_tag.attrs["converter-mark"] = "bad-link" - self.logger.log(f"Error in {toc_href}." + self.logger.log(f"Error in {html_href_from_toc}." f" While processing {internal_link_tag} no anchor found." - f" Should be anchor with new id={new_id} in" - f" {a_tag_href_matched_to_toc} file." - f" Old id={a_tag_id}") + f" Should be anchor with new id={new_unique_id} in" + f" {html_href_of_anchor} file." + f" Old id={id_}") # 1. make ids to be unique in all documents make_ids_unique() # 2a. process anchor which is a whole htm|html|xhtml file diff --git a/src/style_reader.py b/src/style_reader.py index 8831f9a..d178e32 100644 --- a/src/style_reader.py +++ b/src/style_reader.py @@ -1,6 +1,6 @@ import re import cssutils -from typing import List, Tuple, Union +from typing import List, Tuple from os.path import dirname, normpath, join from src.util.color_reader import str2hex @@ -74,7 +74,7 @@ class StyleReader: def convert_size_number(size_number: str, unit_to_replace: str, multiplier: float) -> str: size_number = float(size_number.replace(unit_to_replace, "")) * multiplier return str(size_number) + "px" - has_size = re.search(r"(\d+)([\w%]+)", size_value) + has_size = re.search(r"(\d+(?:\.\d+)?)([\w%]+)", size_value) values: List = size_value.split(" ") if has_size: size_number_idx = [i for i, value in enumerate(values) if re.search("(\d+)([\w%]+)", value)][0] diff --git a/src/util/helpers.py b/src/util/helpers.py index ca95606..d5ce7f8 100644 --- a/src/util/helpers.py +++ b/src/util/helpers.py @@ -1,4 +1,5 @@ import os +import time import logging from typing import Union @@ -51,12 +52,17 @@ class BookLogger: self.main_logger = main_logger self.logger = logging.getLogger(name) self.logger.propagate = False + folder_path = os.path.dirname( os.path.dirname(os.path.abspath(__file__))) - folder_path = os.path.dirname(folder_path) - filename = f"logs/{book_id}.log" + folder_path = os.path.join(os.path.dirname(folder_path), f"logs/{time.strftime('%d-%m-%Y_%H-00')}/") + filename = f"{book_id}.log" file_path = os.path.join(folder_path, filename) + + if not os.path.exists(folder_path): + os.makedirs(folder_path + time.strftime("%Y-%m-%_%H")) file_handler = logging.FileHandler(file_path, mode=filemode) + file_format = logging.Formatter(logging_format) file_handler.setFormatter(file_format) self.logger.addHandler(file_handler)