Skip to content

Commit

Permalink
Catch ValueError in clean_fandom_page when looking for subheadings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius committed Mar 12, 2024
1 parent aca75be commit 4acdf9e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions exts/fandom_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,24 @@ def clean_fandom_page(element: etree._Element) -> etree._Element: # type: ignor

toc = element.find(".//div[@id='toc']")
if toc is not None:
if element.index(toc) > summary_end_index:
summary_end_index = element.index(toc)
try:
index = element.index(toc)
except ValueError:
pass
else:
if index > summary_end_index:
summary_end_index = index
toc.getparent().remove(toc) # type: ignore [reportOptionalMemberAccess]

subheading = element.find(".//h2")
if subheading is not None:
if element.index(subheading) > summary_end_index:
summary_end_index = element.index(subheading)
try:
index = element.index(subheading)
except ValueError:
pass
else:
if index > summary_end_index:
summary_end_index = index
subheading.getparent().remove(subheading) # type: ignore [reportOptionalMemberAccess]

if summary_end_index != 0:
Expand Down

0 comments on commit 4acdf9e

Please sign in to comment.