From 01c105c50c6089065aeba0b7a615586c00370baf Mon Sep 17 00:00:00 2001 From: clime Date: Nov 08 2016 15:47:51 +0000 Subject: Fix #68 'list' object has no attribute 'username' on pgimport push --- diff --git a/pagure_importer/utils/__init__.py b/pagure_importer/utils/__init__.py index 5debda2..6aa3e4d 100644 --- a/pagure_importer/utils/__init__.py +++ b/pagure_importer/utils/__init__.py @@ -123,44 +123,24 @@ def generate_json_for_github_issue_commentors(github_username, github_password, github_project_name): ''' Will create a json file containing details of all the user - who have commented on any issue in the given project + who have commented on or filed any issue in the given project ''' github_obj = Github(github_username, github_password) otp_auth = get_auth_token(github_obj) github_obj = Github(otp_auth) project = github_obj.get_repo(github_project_name) - issue_comment_url = project.issue_comment_url.replace('{/number}', '') - - page = 0 issue_commentors = [] - while True: - page += 1 - payload = {'page': page} - data_ = json.loads(requests.get( - issue_comment_url, params=payload, - auth=HTTPBasicAuth(github_username, github_password)).text) - - if not data_: - break - for data in data_: - try: - commentor = data['user']['login'] - except TypeError: - click.echo('Maybe one of the issue commentors have been\ - dropped because of lack of details') - continue + for issue in project.get_issues(state='all'): + if not issue.user.login in issue_commentors: + issue_commentors.append(issue.user.login) + click.echo('commentor added: ' + issue.user.login) - present = False - for i in issue_commentors: - if i == commentor: - present = True - break - - if not present: - click.echo('commentor added: ' + commentor) - issue_commentors.append(commentor) + for comment in project.get_issues_comments(): + if not comment.user.login in issue_commentors: + issue_commentors.append(comment.user.login) + click.echo('commentor added: ' + comment.user.login) with open('issue_commentors.json', 'w') as f: f.write(json.dumps(issue_commentors)) diff --git a/pagure_importer/utils/importer_github.py b/pagure_importer/utils/importer_github.py index e53c1f4..dde829e 100644 --- a/pagure_importer/utils/importer_github.py +++ b/pagure_importer/utils/importer_github.py @@ -74,7 +74,8 @@ class GithubImporter(): pagure_issue_user = models.User( name=github_issue.user.login, fullname=github_issue.user.name, - emails=[github_issue.user.email]) + emails=[github_issue.user.email] if github_issue.user.email + else [github_get_commentor_email(github_issue.user.login)]) pagure_issue = models.Issue( id=None,