本文整理汇总了Python中github3.GitHub.issues_on方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.issues_on方法的具体用法?Python GitHub.issues_on怎么用?Python GitHub.issues_on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github3.GitHub
的用法示例。
在下文中一共展示了GitHub.issues_on方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: issues
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import issues_on [as 别名]
def issues():
testToIssue = {}
try:
# user = GitHub("<user>",token="<token>")
user = GitHub()
issues = user.issues_on("assaft", "caevo",state="open")
regex = r"\btest\b ([tT]\d+)"
group = 1
for issue in issues:
text = "Issue by " + issue.user.login + ":\n" + issue.title + "\n" + issue.body + "\n\n"
for comment in issue.comments():
text = text + "commit by " + comment.user.login + ":\n" + comment.body + "\n\n"
matches = re.finditer(regex, text)
for match in matches:
test = match.group(group)
#print test
if (test not in testToIssue):
testToIssue[test] = set()
testIssues = testToIssue[test]
testIssues.add(issue.number)
except ForbiddenError as err:
print ('Issues cannot be fetched from GitHub because connection as an anonymous user has failed. Wait for GitHub counter to reset or put your username and password/token in the script. Message from GitHub:\n' + format(err));
except:
sys.exit('Unexpected error fetching issues from GitHub')
return testToIssue;
示例2: ServiceGithub
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import issues_on [as 别名]
class ServiceGithub(ServicesMgr):
def __init__(self, token=None, **kwargs):
super(ServiceGithub, self).__init__(token, **kwargs)
self.scope = ['public_repo']
self.REQ_TOKEN = 'https://github.com/login/oauth/authorize'
self.AUTH_URL = 'https://github.com/login/oauth/authorize'
self.ACC_TOKEN = 'https://github.com/login/oauth/access_token'
self.username = settings.TH_GITHUB['username']
self.password = settings.TH_GITHUB['password']
self.consumer_key = settings.TH_GITHUB['consumer_key']
self.consumer_secret = settings.TH_GITHUB['consumer_secret']
self.token = token
self.oauth = 'oauth1'
self.service = 'ServiceGithub'
if self.token:
token_key, token_secret = self.token.split('#TH#')
self.gh = GitHub(token=token_key)
else:
self.gh = GitHub(username=self.username, password=self.password)
def gh_footer(self, trigger, issue):
link = 'https://github.com/{0}/{1}/issues/{2}'.format(
trigger.repo, trigger.project, issue.id)
provided_by = _('Provided by')
provided_from = _('from')
footer_from = "<br/><br/>{} <em>{}</em> {} <a href='{}'>{}</a>"
return footer_from.format(provided_by, trigger.trigger.description,
provided_from, link, link)
def read_data(self, **kwargs):
"""
get the data from the service
:param kwargs: contain keyword args : trigger_id at least
:type kwargs: dict
:rtype: list
"""
trigger_id = kwargs.get('trigger_id')
date_triggered = str(kwargs.get('date_triggered')).replace(' ', 'T')
data = list()
if self.token:
# check if it remains more than 1 access
# then we can create an issue
if self.gh.ratelimit_remaining > 1:
import pypandoc
trigger = Github.objects.get(trigger_id=trigger_id)
issues = self.gh.issues_on(trigger.repo,
trigger.project,
since=date_triggered)
for issue in issues:
content = pypandoc.convert(issue.body, 'md', format='html')
content += self.gh_footer(trigger, issue)
data.append({'title': issue.title, 'content': content})
cache.set('th_github_' + str(trigger_id), data)
else:
# rate limit reach, do nothing right now
logger.warn("Rate limit reached")
else:
logger.critical("no token provided")
return data
def save_data(self, trigger_id, **data):
"""
let's save the data
:param trigger_id: trigger ID from which to save data
:param data: the data to check to be used and save
:type trigger_id: int
:type data: dict
:return: the status of the save statement
:rtype: boolean
"""
if self.token:
title = self.set_title(data)
body = self.set_content(data)
# get the details of this trigger
trigger = Github.objects.get(trigger_id=trigger_id)
# check if it remains more than 1 access
# then we can create an issue
limit = self.gh.ratelimit_remaining
if limit > 1:
# repo goes to "owner"
# project goes to "repository"
r = self.gh.create_issue(trigger.repo,
trigger.project,
title,
body)
else:
# rate limit reach
logger.warn("Rate limit reached")
# put again in cache the data that could not be
#.........这里部分代码省略.........