Created
February 20, 2020 01:14
-
-
Save lkiesow/4be8a82df524678132c79a5588d2e3c1 to your computer and use it in GitHub Desktop.
Check Fpr Conflicts
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 requests | |
headers = {"Authorization": "token *******************"} | |
def run_query(query): | |
'''A simple function to use requests.post to make the API call. Note the | |
json= section. | |
''' | |
request = requests.post('https://api.github.com/graphql', | |
json={'query': query}, | |
headers=headers) | |
if request.status_code == 200: | |
return request.json() | |
raise Exception('API returned status {request.status_code{i}. {query}') | |
def main(): | |
'''The GraphQL query (with a few aditional bits included) itself defined as | |
a multi-line string. | |
''' | |
query = ''' | |
query { | |
repository(owner:"opencast", name:"opencast") { | |
pullRequests(states: OPEN, last: 100) { | |
edges { | |
node { | |
url | |
title | |
author { login } | |
merged | |
mergeable | |
} | |
} | |
} | |
} | |
} | |
''' | |
result = run_query(query) | |
edges = result["data"]["repository"]["pullRequests"]['edges'] | |
for edge in edges: | |
node = edge['node'] | |
author = node['author']['login'] | |
url = node['url'] | |
title = node['title'] | |
mergeable = node['mergeable'] | |
if mergeable != 'MERGEABLE': | |
print(f'{url}\n {title}\n {author}\n {mergeable}\n') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment