Created
October 12, 2022 02:43
-
-
Save srhopkins/952a424264caf1cc859102642bd5923c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
token = '' | |
def github_request(uri, method='get', **kwargs): | |
'''GitHub API wrapper for auth and baseline vars''' | |
if not uri.startswith('http'): | |
uri = f'https://api.github.com/{uri}' | |
return requests.request(method, uri, headers={ | |
'Authorization': 'token ' + token | |
}, **kwargs) | |
def github_paginator(uri, **kwargs): | |
resp = github_request(uri, **kwargs) | |
yield resp | |
while True: | |
try: | |
resp = next(github_paginator(resp.links['next']['url'], **kwargs)) | |
yield resp | |
except KeyError: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment