Skip to content

Commit

Permalink
Fix failing tests in test_lparchive2epub.py
Browse files Browse the repository at this point in the history
  • Loading branch information
peeley committed Dec 27, 2024
1 parent 44718fe commit 81ff2ec
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 123 deletions.
14 changes: 7 additions & 7 deletions lparchive2epub/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Chapters:
new_href: str

def __hash__(self):
return hash((self.original_href, str(self.txt.string)))
return hash((self.original_href, str(self.txt.text)))

def __post_init__(self):
self.sort_index = self.num
Expand Down Expand Up @@ -75,10 +75,10 @@ def intro(url: str, p: BeautifulSoup) -> Intro:
content = p.find("div", id="content")
chapters = Extractor.all_chapters(url, p)
for c in chapters:
a = content.find("a", text=str(c.txt.string))
a = content.find("a", string=str(c.txt))
a['href'] = c.new_href

images = Extractor.all_images("introduction", content)
images = Extractor.all_images(content)

return Intro(
title=title, language=language, author=author, intro=content, images=images, chapters=chapters
Expand All @@ -101,7 +101,7 @@ def build_chapter(chap: Tuple[int, BeautifulSoup]) -> Chapters:
return Chapters(
num=i,
original_href=original_href,
txt=c,
txt=c.text,
new_href=f"update_{i}.xhtml"
)

Expand All @@ -110,7 +110,7 @@ def build_chapter(chap: Tuple[int, BeautifulSoup]) -> Chapters:
return chapters

@staticmethod
def all_images(prefix: str, content: BeautifulSoup) -> List[Image]:
def all_images(content: BeautifulSoup) -> List[Image]:
images = content.find_all("img")
r = []
for i, x in enumerate(images):
Expand All @@ -125,7 +125,7 @@ def all_images(prefix: str, content: BeautifulSoup) -> List[Image]:
@staticmethod
def get_update(prefix: str, p: BeautifulSoup) -> Update:
content = p.find("div", id="content")
images = Extractor.all_images(prefix, content)
images = Extractor.all_images(content)
return Update(content=content, images=images)


Expand Down Expand Up @@ -184,7 +184,7 @@ def replace_img_name(content: BeautifulSoup, image: IndexedEpubImage) -> Beautif
return content

async def build_update(session: aiohttp.ClientSession, chapter: Chapters, data: Update, intro: Intro) -> Page:
update_chapter = epub.EpubHtml(title=str(chapter.txt.string), file_name=chapter.new_href,
update_chapter = epub.EpubHtml(title=str(chapter.txt), file_name=chapter.new_href,
lang=intro.language) # TODO: fix language
update_chapter.add_item(get_style_item())

Expand Down
Loading

0 comments on commit 81ff2ec

Please sign in to comment.