separate tables by label

pull/977/head
Ben Parsons 7 years ago
parent 1f7fbefd53
commit c58dc59ffe

@ -10,67 +10,84 @@ import re
from datetime import datetime from datetime import datetime
from m2r import convert as m2r from m2r import convert as m2r
pagecount = 1
def getpage(url, page): def getpage(url, page):
resp = requests.get(url + str(page)) resp = requests.get(url + str(page))
json.extend(resp.json())
for link in resp.links.values(): for link in resp.links.values():
if link['rel'] == 'last': if link['rel'] == 'last':
return re.search('page=(.+?)', link['url']).group(1) pagecount = re.search('page=(.+?)', link['url']).group(1)
return resp.json()
def getbylabel(label):
pagecount = 1
json = list()
urlbase = 'https://api.github.com/repos/matrix-org/matrix-doc/issues?state=open&labels=' + label + '&page='
print(urlbase)
json.extend(getpage(urlbase, 1))
for page in range(2, int(pagecount) + 1):
getpage(urlbase, page)
return json
json = list()
# labels = ['p1', p2]
# new status labels: # new status labels:
# proposal-ready-for-review,rejected,stalled,merged,spec-pr-in-review,proposal-wip,proposal-in-review,spec-pr-ready-for-review,proposal-passed-review # proposal-ready-for-review,rejected,stalled,merged,spec-pr-in-review,proposal-wip,proposal-in-review,spec-pr-ready-for-review,proposal-passed-review
urlbase = 'https://api.github.com/repos/matrix-org/matrix-doc/issues?labels=p1,p2,p3,p4,p5&state=open&page=' labels = ['p1', 'p2']
pagecount = getpage('https://api.github.com/repos/matrix-org/matrix-doc/issues?labels=spec-omission&state=open&page=', 1) issues = {}
for page in range(2, int(pagecount) + 1):
getpage(urlbase, page)
for label in labels:
issues[label] = getbylabel(label)
print(issues)
text_file = open("../specification/proposals.rst", "w") text_file = open("../specification/proposals.rst", "w")
text_file.write("Tables\n------------------\n\n.. list-table::\n :header-rows: 1\n\n") text_file.write("Tables\n------------------\n\n")
text_file.write(" * - ID\n")
text_file.write(" - github username\n") for label in labels:
text_file.write(" - proposal title\n") text_file.write(label + "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n")
text_file.write(" - created_at\n") text_file.write(".. list-table::\n :header-rows: 1\n :widths: auto\n\n")
text_file.write(" - updated_at\n") text_file.write(" * - ID\n")
text_file.write(" - maindoc\n") text_file.write(" - github username\n")
text_file.write(" - proposal title\n")
#`matrix-doc/issues <https://github.com/matrix-org/matrix-doc/issues?page=1&q=is%3Aissue+is%3Aopen>`_ text_file.write(" - created_at\n")
for item in json: text_file.write(" - updated_at\n")
maindoc = re.search('Documentation: (.+?)\n', str(item['body'])) text_file.write(" - maindoc\n")
if maindoc is not None:
maindoc = maindoc.group(1) for item in issues[label]:
text_file.write(" * - `" + str(item['number']) + " <" + item['html_url'] + ">`_\n") maindoc = re.search('Documentation: (.+?)\n', str(item['body']))
text_file.write(" - " + item['user']['login'] + "\n") if maindoc is not None:
text_file.write(" - " + item['title'] + "\n") maindoc = maindoc.group(1)
text_file.write(" - " + item['created_at'] + "\n") text_file.write(" * - `" + str(item['number']) + " <" + item['html_url'] + ">`_\n")
text_file.write(" - " + item['updated_at'] + "\n") text_file.write(" - " + item['user']['login'] + "\n")
text_file.write(" - " + str(maindoc) + "\n") text_file.write(" - " + item['title'] + "\n")
text_file.write(" - " + item['created_at'] + "\n")
text_file.write(" - " + item['updated_at'] + "\n")
text_file.write(" - " + str(maindoc) + "\n")
text_file.write("\n\n\n")
text_file.write("\n") text_file.write("\n")
text_file.write("The Proposals List\n------------------\n") # text_file.write("The Proposals List\n------------------\n")
# text_file.write(json[0]['user']['login']) # # text_file.write(json[0]['user']['login'])
for item in json: # for item in json:
# write a header # # write a header
prop_header = item['title'] + " (" + str(item['number']) + ")" # prop_header = item['title'] + " (" + str(item['number']) + ")"
text_file.write(prop_header + "\n") # text_file.write(prop_header + "\n")
text_file.write("~" * len(prop_header)) # text_file.write("~" * len(prop_header))
text_file.write("\n\n") # text_file.write("\n\n")
# write some metadata # # write some metadata
text_file.write(item['created_at'] + "\n") # text_file.write(item['created_at'] + "\n")
text_file.write(item['updated_at'] + "\n") # text_file.write(item['updated_at'] + "\n")
# created = datetime.strptime(item['created_at'], "%Y-%m-%dT%XZ") # # created = datetime.strptime(item['created_at'], "%Y-%m-%dT%XZ")
# write body text # # write body text
body = m2r(str(item['body'])) # body = m2r(str(item['body']))
text_file.write(body + "\n\n\n") # text_file.write(body + "\n\n\n")
text_file.close() text_file.close()

Loading…
Cancel
Save