1

我正在使用 PyGithub 与 GitHub API 进行交互,并试图让受让人和分配者解决问题。我实现了以下代码,似乎受让人名称和分配者名称不正确。例如,clatoolkitdev2clatoolkitdev问题#32分配。但是,我clatoolkitdev2从我的代码中获得了受让人和受让人。

gh = Github(login_or_token = token, per_page = self.parPage)
repo = gh.get_repo(repo_name)
issue = repo.get_issue(issue_number)
issue_events = issue.get_events().get_page(page)

for event in issue_events:
    assignee = event.issue.assignee
    assigner = event.actor

    assigner_id = str(assigner.id)
    assigner_name = str(assigner.login)
    assignee_name = assignee.login

    print '================================================================='
    print 'event ID: ' + str(event_id) + "     " + issue_url
    print 'assigner: %s  assignee: %s' % (assigner_name, assignee_name)

输出:

=================================================================
event ID: 866189924     https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/32
assigner: clatoolkitdev2  assignee: clatoolkitdev2
=================================================================
event ID: 803384175     https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/25
assigner: kojiclatoolkit  assignee: kojiclatoolkit
=================================================================
event ID: 803384176     https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/25
assigner: clatoolkitdev  assignee: kojiclatoolkit
=================================================================
event ID: 852475091     https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/24
assigner: kojiclatoolkit  assignee: kojiclatoolkit
=================================================================
event ID: 852475092     https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/24
assigner: clatoolkitdev  assignee: kojiclatoolkit

我检查了 PyGithub API 参考并用谷歌搜索找到解决方案,但没有得到任何线索。我想知道是我犯了愚蠢的错误还是 PyGithub 中存在错误。

4

1 回答 1

0

问题是 PyGithub(和您的代码)正在读取actor.login事件的属性以获取分配者,这实际上clatoolkitdev2在您提供的 API 响应中。

查看 PyGithub 源代码,它似乎从未assigner从 API 有效负载中读取过属性(既不在Issue.py也不IssueEvent.py),这让我觉得这是一个错误。

于 2016-11-22T09:52:45.647 回答