Created
February 3, 2020 18:28
-
-
Save jb3/a94f2ca1be3bec72f9f5b4e27436b236 to your computer and use it in GitHub Desktop.
This file contains 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 urllib.parse | |
from typing import Union | |
import httpx | |
with open("./github.access") as token_file: | |
token = token_file.read().strip() | |
def get(route: str, arguments: dict = {}) -> Union[dict, list]: | |
return httpx.get( | |
f"https://api.github.com/{route}?{urllib.parse.urlencode(arguments)}", | |
headers={ | |
"Authorization": f"Bearer {token}", | |
"Accept": "application/vnd.github.v3+json" | |
} | |
).json() | |
username = get("user")["login"] | |
pull_requests = get("search/issues", { | |
"q": f"is:open is:pr review-requested:{username} archived:false" | |
}) | |
print("Requiring your review:") | |
for pr in pull_requests["items"]: | |
data = get("/".join(pr["pull_request"]["url"].split("/")[3:]) + "/requested_reviewers") | |
actual_users = data["users"] | |
for user in actual_users: | |
if username == user["login"]: | |
print(f'\t{pr["title"]} - {pr["pull_request"]["html_url"]}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment