本文整理汇总了Python中github3.GitHub.iter_repo_issues方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.iter_repo_issues方法的具体用法?Python GitHub.iter_repo_issues怎么用?Python GitHub.iter_repo_issues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github3.GitHub
的用法示例。
在下文中一共展示了GitHub.iter_repo_issues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import iter_repo_issues [as 别名]
class GitHubApi:
"""
GitHub API interaction using github3
"""
def __init__(self, repo_owner, repo_name, token):
self.repo_owner = repo_owner
self.repo_name = repo_name
self.gh = GitHub(token=token)
def get_issues(self, label=None):
"""Returns all issues (matching label)"""
return self.gh.iter_repo_issues(self.repo_owner, self.repo_name, labels=label)
def get_issue(self, issue_id):
"""Returns issue"""
return self.gh.issue(self.repo_owner, self.repo_name, issue_id)
def get_matching_pull_requests(self, label=None):
"""
Returns all matching issues
Pull requests are treated as issues
"""
pull_request_list = []
for issue in self.get_issues(label):
# Get Pull Request
pull_request_list.append(self.pull_request_information(issue.number))
return pull_request_list
def get_pull_request_status(self, label=None):
"""Returns string containing status of pull requests"""
pull_requests = self.get_matching_pull_requests(label)
pull_requests_information = "Pull Requests - %s\n\n" % label
for pr in pull_requests:
pull_requests_information += "Title: %s\nBranch: %s\nLink: %s\nMergeable: %s\n\n"\
% (pr.title, pr.head.ref, pr.html_url, pr.mergeable)
return pull_requests_information
def pull_request_information(self, pull_request_id):
"""Returns specified pull request"""
pull_request = self.gh.pull_request(self.repo_owner, self.repo_name, pull_request_id)
return pull_request
def assign_new_label_to_issue(self, branch, label, who):
"""Update issue label"""
# Find issue
issue = self.filter_on_branch(self.get_matching_pull_requests(), branch)
# Remove all existing labels
issue.remove_all_labels()
# Add label 'release'
issue.add_labels(label)
# Add comment for tracking
issue.create_comment("%s assigned label '%s' via hipchat" % (who, label))
def filter_on_branch(self, pull_requests, branch):
for pull_request in pull_requests:
if pull_request.head.ref == branch:
# Get issue
return self.get_issue(pull_request.number)