Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests on master #3

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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