本文整理汇总了Python中github.GitHub.issues方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.issues方法的具体用法?Python GitHub.issues怎么用?Python GitHub.issues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.GitHub
的用法示例。
在下文中一共展示了GitHub.issues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import issues [as 别名]
logging.info("Migrating Trac tickets to GitHub...")
for ticket in TracTicket.iter_tickets():
if ticket.tid < options.ticket_start:
continue
if options.ticket_end > -1 and ticket.tid > options.ticket_end:
break
logging.info("Ticket %d: [%s] %s" % (ticket.tid, ticket.owner.strip(), ticket.summary))
if options.comments_only:
gid = ticket.tid
else:
# We can't find out the github ticket number in advance, so attempt to add
# ticket and see what number results
issue = ticket.get_github_summary_data()
gh_issue = github.issues(data=issue)
gid = gh_issue['number']
# If the ticket number isn't what we expect, handle two cases
if gid < ticket.tid:
# If github is behind Trac, just add a bunch of dummy tickets
TracTicket.replace_with_dummy(gid)
while gid < ticket.tid - 1:
gid = TracTicket.add_dummy_ticket()
# Re-add ticket, this time in the correct spot
issue = ticket.get_github_data(milestone_id, labels)
gh_issue = github.issues(data=issue)
gid = gh_issue['number']
elif gid > ticket.tid:
logging.error("Github ticket numbering is ahead of track numbering and can't be used.")
示例2:
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import issues [as 别名]
issue['milestone'] = m
if component:
github.addlabel(component, labels, issue, logging)
if type:
# Map 'defect' to 'bug'
if type == 'defect':
type = 'bug'
github.addlabel(type, labels, issue, logging)
if priority:
github.addlabel(priority, labels, issue, logging)
# We have to create/map Trac users to GitHub usernames before we can assign
# them to tickets; don't see how to do that conveniently now.
# if owner.strip():
# ticket['assignee'] = owner.strip()
gh_issue = github.issues(data=issue)
# Add comments
comments = trac.sql('SELECT author, newvalue AS body FROM ticket_change WHERE field="comment" AND ticket=%s' % tid)
for author, body in comments:
body = body.strip()
if body:
# prefix comment with author as git doesn't keep them separate
if author:
body = "[%s] %s" % (author, body)
logging.debug('issue comment: %s' % body[:40]) # TODO: escape newlines
github.issue_comments(gh_issue['number'], data={'body': body})
# Close tickets if they need it.
# The v3 API says we should use PATCH, but
# http://developer.github.com/v3/ says POST is supported.
if status == 'closed':
github.issues(id_=gh_issue['number'], data={'state': 'closed'})
示例3:
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import issues [as 别名]
description += "\n\n"
description += "trac data:\n"
description += " * Owner: **%s**\n" % owner
description += " * Reporter: **%s**\n" % reporter
description += " * Reported at: **%s**\n" % datetime.datetime.fromtimestamp(timestamp).ctime()
description += " * URL: %s/ticket/%d" % (trac_url, tid)
issue["body"] = description
if milestone and options.milestones:
m = milestone_id.get(milestone)
if m:
issue["milestone"] = m
# We have to create/map Trac users to GitHub usernames before we can assign
# them to tickets; don't see how to do that conveniently now.
# if owner.strip():
# ticket['assignee'] = owner.strip()
gh_issue = github.issues(data=issue)
# Add comments
comments = trac.sql('SELECT author, newvalue AS body FROM ticket_change WHERE field="comment" AND ticket=%s' % tid)
for author, body in comments:
body = body.strip()
if body:
# prefix comment with author as git doesn't keep them separate
if author:
body = "[%s] %s" % (author, body)
logging.debug("issue comment: %s" % body[:40]) # TODO: escape newlines
github.issue_comments(gh_issue["number"], data={"body": body})
# Close tickets if they need it.
# The v3 API says we should use PATCH, but
# http://developer.github.com/v3/ says POST is supported.
if status == "closed":
github.issues(id_=gh_issue["number"], data={"state": "closed"})