Created
March 27, 2016 10:07
-
-
Save SensibleWood/54a6c945902503a35aa0 to your computer and use it in GitHub Desktop.
A simple script to dump issues with a given label from Github repo to markdown
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 | |
"""A simple script to pull issues from Github and format them as Markdown - writes to stdout""" | |
from urllib3 import PoolManager, disable_warnings | |
from base64 import b64encode | |
from argparse import ArgumentParser | |
from jq import jq | |
disable_warnings() | |
def init_args(): | |
parser = ArgumentParser() | |
parser.add_argument("repo") | |
parser.add_argument("username") | |
parser.add_argument("password") | |
parser.add_argument("label") | |
return parser.parse_args() | |
if __name__ == '__main__': | |
http = PoolManager() | |
args = init_args() | |
response = http.urlopen( | |
'GET', args.repo, | |
headers={'Authorization': 'Basic %s' % b64encode(('%s:%s' % (args.username, args.password)) | |
.encode()).decode('utf-8'), | |
'User-Agent': 'python'}) | |
if response.status == 200: | |
issues = jq('select(.[].labels[].name == "%s")' % args.label).transform(text=response.data.decode('utf-8')) | |
for issue in sorted(issues, key=lambda k: k['number']): | |
print("## #%s: %s" % (issue["number"], issue["title"])) | |
print() | |
for line in issue["body"].split("\n"): | |
print(line) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment