Created
July 18, 2017 11:39
-
-
Save grahamhayes/ef84553e031593d47bff86f1a2105762 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
#!/usr/bin/env python | |
try: | |
import requests | |
except ImportError: | |
print("Please install python-requests") | |
raise SystemExit(1) | |
import argparse | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Get Lists of Backport PRs for Kubic') | |
parser.add_argument('--token', metavar='token', help='Github API token for User', default=None) | |
parser.add_argument('--user', metavar='user', help='User to authenticate as for API', default=None) | |
parser.add_argument('--label', metavar='label', help='Which label to query', default='all') | |
args = parser.parse_args() | |
prs = {} | |
url = 'https://api.github.com/search/issues' | |
if args.user: | |
auth=(args.user, args.token) | |
else: | |
auth=None | |
if args.label is 'all': | |
for label in ['release-1.0-candidate', 'release-1.0-backport', 'release-1.0-backport-merged']: | |
params = {'q': 'is:pr label:%s org:kubic-project' % label} | |
prs[label] = [] | |
data = requests.get(url, params=params, auth=auth) | |
for pr in data.json()['items']: | |
prs[label].append(pr) | |
else: | |
data = requests.get(url % {'label': args.label}).json() | |
for pr in data['items']: | |
prs.add(pr) | |
for label in prs.iterkeys(): | |
print("*********** %s ***********" % label) | |
for pr in prs[label]: | |
print(" %(html_url)s ::: %(title)s :::" % pr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment