Revert "black: re-format"
This reverts commit 5731818de0ce446ceaafc7e75ae39da1b69942ae.
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
Change-Id: Ie61cdc8c7f2825b0d9d66be87a6a3a058de2b372
diff --git a/tools/github_issues_to_csv b/tools/github_issues_to_csv
index ce6e1e2..c287f7c 100644
--- a/tools/github_issues_to_csv
+++ b/tools/github_issues_to_csv
@@ -8,11 +8,10 @@
import argparse
import csv
import getpass
-
import requests
auth = None
-states = "all"
+states = 'all'
def write_issues(response, csv_out):
@@ -23,45 +22,36 @@
if response.status_code != 200:
raise Exception(response.status_code)
for issue in response.json():
- if "pull_request" not in issue:
- labels = ", ".join([lable["name"] for lable in issue["labels"]])
+ if 'pull_request' not in issue:
+ labels = ', '.join([lable['name'] for lable in issue['labels']])
# Below lines to overcome "TypeError: 'NoneType' object has
# no attribute '__getitem__'"
- close_date = issue.get("closed_at")
+ close_date = issue.get('closed_at')
if close_date:
- close_date = issue.get("closed_at").split("T")[0]
+ close_date = issue.get('closed_at').split('T')[0]
- assignee_resp = issue.get("assignees", "Not Assigned")
+ assignee_resp = issue.get('assignees', 'Not Assigned')
if assignee_resp:
- owners = ",".join(
- [
- assignee_login["login"]
- for assignee_login in assignee_resp
- ]
- )
+ owners = ','.join([assignee_login['login'] for
+ assignee_login in assignee_resp])
else:
owners = "Not Assigned"
- milestone_resp = issue.get("milestone", "Not Assigned")
+ milestone_resp = issue.get('milestone', 'Not Assigned')
if milestone_resp:
- milestone_resp = milestone_resp["title"].encode("utf-8")
+ milestone_resp = milestone_resp['title'].encode('utf-8')
# Change the following line to write out additional fields
- csv_out.writerow(
- [
- labels.encode("utf-8"),
- issue.get("title").encode("utf-8"),
- issue.get("state").encode("utf-8"),
- issue.get("created_at").split("T")[0],
- close_date,
- issue.get("html_url").encode("utf-8"),
- issue.get("user").get("login").encode("utf-8"),
- owners,
- milestone_resp,
- ]
- )
+ csv_out.writerow([labels.encode('utf-8'),
+ issue.get('title').encode('utf-8'),
+ issue.get('state').encode('utf-8'),
+ issue.get('created_at').split('T')[0],
+ close_date,
+ issue.get('html_url').encode('utf-8'),
+ issue.get('user').get('login').encode('utf-8'),
+ owners, milestone_resp])
def get_issues_from_github_to_csv(name, response):
@@ -75,49 +65,36 @@
print(states)
# Multiple requests are required if response is paged
- if "link" in response.headers:
- pages = {
- rel[6:-1]: url[url.index("<") + 1 : -1]
- for url, rel in (
- link.split(";") for link in response.headers["link"].split(",")
- )
- }
- while "last" in pages and "next" in pages:
- pages = {
- rel[6:-1]: url[url.index("<") + 1 : -1]
- for url, rel in (
- link.split(";")
- for link in response.headers["link"].split(",")
- )
- }
- response = requests.get(pages["next"], auth=auth)
+ if 'link' in response.headers:
+ pages = {rel[6:-1]: url[url.index('<') + 1:-1] for url, rel in
+ (link.split(';') for link in
+ response.headers['link'].split(','))}
+ while 'last' in pages and 'next' in pages:
+ pages = {rel[6:-1]: url[url.index('<') + 1:-1] for url, rel in
+ (link.split(';') for link in
+ response.headers['link'].split(','))}
+ response = requests.get(pages['next'], auth=auth)
write_issues(response, csv_out)
- if pages["next"] == pages["last"]:
+ if pages['next'] == pages['last']:
break
-parser = argparse.ArgumentParser(
- description="Write GitHub repository issues to CSV file."
-)
+parser = argparse.ArgumentParser(description="Write GitHub repository issues "
+ "to CSV file.")
-parser.add_argument(
- "username", nargs="?", help="GitHub user name, formatted as 'username'"
-)
+parser.add_argument('username', nargs='?', help="GitHub user name, "
+ "formatted as 'username'")
-parser.add_argument(
- "repositories",
- nargs="+",
- help="Repository names, formatted as 'basereponame/repo'",
-)
+parser.add_argument('repositories', nargs='+', help="Repository names, "
+ "formatted as 'basereponame/repo'")
-parser.add_argument(
- "--all", action="store_true", help="Returns both open and closed issues."
-)
+parser.add_argument('--all', action='store_true', help="Returns both open "
+ "and closed issues.")
args = parser.parse_args()
if args.all:
- state = "all"
+ state = 'all'
username = args.username
@@ -128,26 +105,16 @@
# To set the csv filename
csvfilename = ""
for repository in args.repositories:
- csvfilename_temp = "{}".format(repository.replace("/", "-"))
+ csvfilename_temp = '{}'.format(repository.replace('/', '-'))
csvfilename = csvfilename + csvfilename_temp
-csvfilename = csvfilename + "-issues.csv"
-with open(csvfilename, "w") as csvfileout:
+csvfilename = csvfilename + '-issues.csv'
+with open(csvfilename, 'w') as csvfileout:
csv_out = csv.writer(csvfileout)
- csv_out.writerow(
- [
- "Labels",
- "Title",
- "State",
- "Open Date",
- "Close Date",
- "URL",
- "Author",
- "Assignees",
- "Milestone",
- ]
- )
+ csv_out.writerow(['Labels', 'Title', 'State', 'Open Date',
+ 'Close Date', 'URL', 'Author', 'Assignees',
+ 'Milestone'])
for repository in args.repositories:
- l_url = "https://api.github.com/repos/{}/issues?state={}"
+ l_url = 'https://api.github.com/repos/{}/issues?state={}'
l_url = l_url.format(repository, states)
response = requests.get(l_url, auth=auth)
write_issues(response, csv_out)