本文整理汇总了Python中osclib.comments.CommentAPI.command_find方法的典型用法代码示例。如果您正苦于以下问题:Python CommentAPI.command_find方法的具体用法?Python CommentAPI.command_find怎么用?Python CommentAPI.command_find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.comments.CommentAPI
的用法示例。
在下文中一共展示了CommentAPI.command_find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReviewBot
# 需要导入模块: from osclib.comments import CommentAPI [as 别名]
# 或者: from osclib.comments.CommentAPI import command_find [as 别名]
#.........这里部分代码省略.........
good = True
if good is None:
self.logger.info("%s ignored"%req.reqid)
elif good:
self._set_review(req, 'accepted')
elif self.review_mode != 'accept-onpass':
self._set_review(req, 'declined')
@memoize(session=True)
def request_override_check_users(self, project):
"""Determine users allowed to override review in a comment command."""
config = Config.get(self.apiurl, project)
users = []
group = config.get('staging-group')
if group:
users += group_members(self.apiurl, group)
if self.override_group_key:
override_group = config.get(self.override_group_key)
if override_group:
users += group_members(self.apiurl, override_group)
return users
def request_override_check(self, request, force=False):
"""Check for a comment command requesting review override."""
if not force and not self.override_allow:
return None
comments = self.comment_api.get_comments(request_id=request.reqid)
users = self.request_override_check_users(request.actions[0].tgt_project)
for args, who in self.comment_api.command_find(
comments, self.review_user, 'override', users):
message = 'overridden by {}'.format(who)
override = args[1] if len(args) >= 2 else 'accept'
if override == 'accept':
self.review_messages['accepted'] = message
return True
if override == 'decline':
self.review_messages['declined'] = message
return False
def _set_review(self, req, state):
doit = self.can_accept_review(req.reqid)
if doit is None:
self.logger.info("can't change state, %s does not have the reviewer"%(req.reqid))
newstate = state
by_user = self.fallback_user
by_group = self.fallback_group
msg = self.review_messages[state] if state in self.review_messages else state
self.logger.info("%s %s: %s"%(req.reqid, state, msg))
if state == 'declined':
if self.review_mode == 'fallback-onfail':
self.logger.info("%s needs fallback reviewer"%req.reqid)
self.add_review(req, by_group=by_group, by_user=by_user, msg="Automated review failed. Needs fallback reviewer.")
newstate = 'accepted'
elif self.review_mode == 'fallback-always':
self.add_review(req, by_group=by_group, by_user=by_user, msg='Adding fallback reviewer')