1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

tools/issues: fix weights and add auth

This commit is contained in:
Tomas Susanka 2019-10-03 12:01:27 +00:00
parent 07b4f6e399
commit f09bc4dd77

View File

@ -8,7 +8,8 @@ import csv
from getpass import getpass from getpass import getpass
import requests import requests
auth = None auth_id = None
auth_secret = None
PRIORITIES = ("P1", "P2", "P3", "P4") PRIORITIES = ("P1", "P2", "P3", "P4")
SEVERITIES = ("S1", "S2", "S3", "S4") SEVERITIES = ("S1", "S2", "S3", "S4")
@ -29,7 +30,7 @@ def write_issues(r, csvout):
priority = l["name"] priority = l["name"]
elif l["name"][:2] in SEVERITIES: elif l["name"][:2] in SEVERITIES:
severity = l["name"] severity = l["name"]
elif l["name"][:2] in WEIGHTS: elif l["name"] in WEIGHTS:
weight = l["name"][1:] weight = l["name"][1:]
if weight == "1/2": if weight == "1/2":
weight = "0.5" weight = "0.5"
@ -47,8 +48,11 @@ def write_issues(r, csvout):
def get_issues(name): def get_issues(name):
"""Requests issues from GitHub API and writes to CSV file.""" """Requests issues from GitHub API and writes to CSV file."""
url = 'https://api.github.com/repos/{}/issues?state=all'.format(name) if auth_secret:
r = requests.get(url, auth=auth) url = 'https://api.github.com/repos/{}/issues?state=all&client_id={}&client_secret={}'.format(name, auth_id, auth_secret)
else:
url = 'https://api.github.com/repos/{}/issues?state=all'.format(name)
r = requests.get(url)
csvfilename = '{}-issues.csv'.format(name.replace('/', '-')) csvfilename = '{}-issues.csv'.format(name.replace('/', '-'))
with open(csvfilename, 'w', newline='') as csvfile: with open(csvfilename, 'w', newline='') as csvfile:
@ -65,7 +69,7 @@ def get_issues(name):
pages = {rel[6:-1]: url[url.index('<')+1:-1] for url, rel in pages = {rel[6:-1]: url[url.index('<')+1:-1] for url, rel in
(link.split(';') for link in (link.split(';') for link in
r.headers['link'].split(','))} r.headers['link'].split(','))}
r = requests.get(pages['next'], auth=auth) r = requests.get(pages['next'])
write_issues(r, csvout) write_issues(r, csvout)
if pages['next'] == pages['last']: if pages['next'] == pages['last']:
break break