Skip to content

Commit

Permalink
Simplify loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mering committed Aug 22, 2023
1 parent a5dde1f commit ad317b1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions clean_ghcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ def get_req(path, params=None):
if "per_page" not in params:
params["per_page"] = PER_PAGE
url = get_url(path)
another_page = True
result = []
while another_page:
while True:
response = requests.get(url, headers=get_base_headers(), params=params)
if not response.ok:
raise Exception(response.text)
result.extend(response.json())
if "next" in response.links:
url = response.links["next"]["url"]
if "page" in params:
del params["page"]
else:
another_page = False

if "next" not in response.links:
break
url = response.links["next"]["url"]
if "page" in params:
del params["page"]
return result


Expand Down

0 comments on commit ad317b1

Please sign in to comment.