Skip to content

Commit

Permalink
Handle index pages with not body element
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicWink committed Aug 4, 2022
1 parent 7cffb54 commit a23bffa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/proxpi/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _list_packages(self):
self._index_t = time.monotonic()

root = tree.getroot()
body = next(b for b in root if b.tag == "body")
body = next((b for b in root if b.tag == "body"), root)
for child in body:
if child.tag == "a":
name = _name_normalise_re.sub("-", child.text).lower()
Expand Down Expand Up @@ -223,7 +223,7 @@ def _list_files(self, package_name: str):
tree = lxml.etree.parse(io.BytesIO(response.content), _html_parser)

root = tree.getroot()
body = next(b for b in root if b.tag == "body")
body = next((b for b in root if b.tag == "body"), root)
for child in body:
if child.tag == "a":
name = child.text
Expand Down

0 comments on commit a23bffa

Please sign in to comment.