Skip to content

Instantly share code, notes, and snippets.

@lidaobing
Created March 11, 2019 17:09
Show Gist options
  • Save lidaobing/fbcba9883279cc78153fb5c726a14563 to your computer and use it in GitHub Desktop.
Save lidaobing/fbcba9883279cc78153fb5c726a14563 to your computer and use it in GitHub Desktop.
#!/usr/bin/env /usr/local/bin/python3
import netrc
import requests
import json
class Task:
def __init__(self, number, title, url, assignee):
self.number = number
self.title = title
self.url = url
self.assignee = assignee
def get_all_tasks():
page = 1
res = []
while True:
tasks = get_tasks_for_page(page)
if len(tasks) == 0:
break
res.extend(tasks)
page += 1
return res
def get_tasks_for_page(page):
a = netrc.netrc()
username, _, password = a.authenticators('api.github.com')
url = "https://api.github.com/repos/lidaobing/private/issues?page=%s" % page
content = requests.get(url, auth=(username, password)).content
j = json.loads(content)
res = []
for j0 in j:
assignee = None
if j0['assignee'] is not None:
assignee = j0['assignee']
res.append(Task(j0['number'], j0['title'], j0['html_url'], assignee))
return res
def main():
tasks = get_all_tasks()
assigned_tasks = [x for x in tasks if x.assignee is not None]
unassigned_tasks = [x for x in tasks if x.assignee is None]
print('🤹(%d/%d)' % (len(assigned_tasks), len(unassigned_tasks)))
print('---')
print('Refresh | refresh=true')
print('---')
for x in assigned_tasks:
print("#%s: %s | href=%s" % (x.number, x.title, x.url))
print('---')
for x in unassigned_tasks:
print("#%s: %s | href=%s" % (x.number, x.title, x.url))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment