Add attr replacer & svg -> img

This commit is contained in:
Kiryl
2022-07-20 15:45:44 +03:00
parent 4f7aa69ab3
commit ea4dd77155
3 changed files with 39 additions and 14 deletions

View File

@@ -27,7 +27,7 @@ def save_image_locally(img_file_path: str, img_content: bytes, book_id: str):
def update_images_src_links(body_tag: BeautifulSoup,
href2img_content: dict,
img_href2img_content: dict,
path_to_html: str,
access=None,
path2aws_path: dict = None,
@@ -40,10 +40,10 @@ def update_images_src_links(body_tag: BeautifulSoup,
path_to_img_from_root = os.path.normpath(os.path.join(
html_folder, path_to_img_from_html)).replace("\\", "/")
assert path_to_img_from_root in href2img_content, \
assert path_to_img_from_root in img_href2img_content, \
f"Image {path_to_img_from_html} in file {path_to_html} was not added to manifest."
img_content = href2img_content[path_to_img_from_root]
img_content = img_href2img_content[path_to_img_from_root]
if access is not None:
if path_to_img_from_root in path2aws_path:
new_folder = path2aws_path[path_to_img_from_root]