in gh-data.py [0:0]
def main():
# update
data = []
page = 1
while True:
try:
print(f"Fetching page {page}...")
response = requests.get(
f"https://api.github.com/repos/mozilla/standards-positions/issues?direction=asc&state=all&per_page=100&page={page}",
headers=headers,
timeout=5,
)
response.raise_for_status()
except Exception:
print("Update failed, network failure or request timed out.")
exit(1)
temp_data = response.json()
if not temp_data:
print("Empty!")
break
data.extend(temp_data)
# Check for 'link' header and 'rel="next"'
link_header = response.headers.get("link", "")
if 'rel="next"' not in link_header:
break
page += 1
write_json("gh-data.json", data)
print("Done: gh-data.json.")
# process
if not os.path.exists("gh-data.json"):
print("Sorry, you have to update first.")
exit(1)
with open("gh-data.json", "rb") as f:
data = json.load(f)
process(data)