Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
try to prevent missing title in node
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Apr 1, 2021
1 parent 85412b1 commit c68add4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sushichef.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ def units(self):
for url in self:
topic = Topic(url.attrs.get("href"), title=url.text)
for link in topic:
course_index = CourseIndex(link.text, link.attrs.get("href"))
course_index = CourseIndex(
link.text or link.attrs.get("title"), link.attrs.get("href")
)
course_index.description = link.attrs.get("title")
path = [
DATA_DIR,
Expand All @@ -326,7 +328,8 @@ def units(self):
base_path = [DATA_DIR, DATA_DIR_SUBJECT, hashed(self.title)]
for chapter_link in self:
course_index = CourseIndex(
chapter_link.text, chapter_link.attrs.get("href", "")
chapter_link.text or chapter_link.attrs.get("title"),
chapter_link.attrs.get("href", ""),
)
course_index.description = chapter_link.attrs.get("title")
course_index.thumbnail = self.thumbnails_links.get(
Expand All @@ -346,7 +349,8 @@ def units(self):
base_path = [DATA_DIR, DATA_DIR_SUBJECT, hashed(self.title)]
for chapter_link in self:
course_index = CourseIndex(
chapter_link.text, chapter_link.attrs.get("href", "")
chapter_link.text or chapter_link.attrs.get("title"),
chapter_link.attrs.get("href", ""),
)
course_index.description = chapter_link.attrs.get("title")
course_index.thumbnail = self.thumbnails_links.get(
Expand All @@ -372,7 +376,8 @@ def units(self):
]:
continue
course_index = CourseIndex(
chapter_link.text, chapter_link.attrs.get("href", "")
chapter_link.text or chapter_link.attrs.get("title"),
chapter_link.attrs.get("href", ""),
)
course_index.description = chapter_link.attrs.get("title")
course_index.thumbnail = self.thumbnails_links.get(
Expand Down Expand Up @@ -583,7 +588,7 @@ def index(self, base_path):
pass
else:
course_index = CourseIndex(
course_link_name,
course_link_name or course_link.attrs.get("title"),
course_link_href,
visited_urls=self.visited_urls,
)
Expand Down

0 comments on commit c68add4

Please sign in to comment.