当前位置: 首页>>代码示例>>Python>>正文


Python IRCBot.irc_delegate方法代码示例

本文整理汇总了Python中webkitpy.tool.bot.ircbot.IRCBot.irc_delegate方法的典型用法代码示例。如果您正苦于以下问题:Python IRCBot.irc_delegate方法的具体用法?Python IRCBot.irc_delegate怎么用?Python IRCBot.irc_delegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webkitpy.tool.bot.ircbot.IRCBot的用法示例。


在下文中一共展示了IRCBot.irc_delegate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SheriffBot

# 需要导入模块: from webkitpy.tool.bot.ircbot import IRCBot [as 别名]
# 或者: from webkitpy.tool.bot.ircbot.IRCBot import irc_delegate [as 别名]
class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
    name = "webkitbot"
    watchers = AbstractQueue.watchers + ["[email protected]", "[email protected]"]

    # AbstractQueue methods

    def begin_work_queue(self):
        AbstractQueue.begin_work_queue(self)
        self._sheriff = Sheriff(self._tool, self)
        self._irc_bot = IRCBot(self.name, self._tool, self._sheriff, irc_commands)
        self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())

    def work_item_log_path(self, failure_map):
        return None

    def _is_old_failure(self, revision):
        return self._tool.status_server.svn_revision(revision)

    def next_work_item(self):
        self._irc_bot.process_pending_messages()
        return

    def process_work_item(self, failure_map):
        return True

    def handle_unexpected_error(self, failure_map, message):
        _log.error(message)

    # StepSequenceErrorHandler methods

    @classmethod
    def handle_script_error(cls, tool, state, script_error):
        # Ideally we would post some information to IRC about what went wrong
        # here, but we don't have the IRC password in the child process.
        pass
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:37,代码来源:sheriffbot.py

示例2: NewCommitBot

# 需要导入模块: from webkitpy.tool.bot.ircbot import IRCBot [as 别名]
# 或者: from webkitpy.tool.bot.ircbot.IRCBot import irc_delegate [as 别名]
class NewCommitBot(AbstractQueue, StepSequenceErrorHandler):
    name = "new-commit-bot"
    watchers = AbstractQueue.watchers + ["[email protected]"]

    _commands = {
        "ping": PingPong,
        "restart": Restart,
    }

    # AbstractQueue methods

    def begin_work_queue(self):
        AbstractQueue.begin_work_queue(self)
        self._last_svn_revision = int(self._tool.scm().head_svn_revision())
        self._irc_bot = IRCBot('WKR', self._tool, None, self._commands)
        self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())

    def work_item_log_path(self, failure_map):
        return None

    def next_work_item(self):
        self._irc_bot.process_pending_messages()

        _log.info('Last SVN revision: %d' % self._last_svn_revision)

        _log.info('Updating checkout')
        self._update_checkout()

        _log.info('Obtaining new SVN revisions')
        revisions = self._new_svn_revisions()

        _log.info('Obtaining commit logs for %d revisions' % len(revisions))
        for revision in revisions:
            commit_log = self._tool.scm().svn_commit_log(revision)
            self._tool.irc().post(self._summarize_commit_log(commit_log).encode('ascii', 'ignore'))

        return

    def process_work_item(self, failure_map):
        return True

    def _update_checkout(self):
        tool = self._tool
        tool.executive.run_and_throw_if_fail(tool.deprecated_port().update_webkit_command(), quiet=True, cwd=tool.scm().checkout_root)

    def _new_svn_revisions(self):
        scm = self._tool.scm()
        current_head = int(scm.head_svn_revision())
        first_new_revision = self._last_svn_revision + 1
        self._last_svn_revision = current_head
        return range(max(first_new_revision, current_head - 20), current_head + 1)

    _patch_by_regex = re.compile(r'^Patch\s+by\s+(?P<author>.+?)\s+on(\s+\d{4}-\d{2}-\d{2})?\n?', re.MULTILINE | re.IGNORECASE)
    _rollout_regex = re.compile(r'(rolling out|reverting) (?P<revisions>r?\d+((,\s*|,?\s*and\s+)?r?\d+)*)\.?\s*', re.MULTILINE | re.IGNORECASE)
    _requested_by_regex = re.compile(r'^\"?(?P<reason>.+?)\"? \(Requested\s+by\s+(?P<author>.+?)\s+on\s+#webkit\)\.', re.MULTILINE | re.IGNORECASE)
    _bugzilla_url_regex = re.compile(r'http(s?)://bugs\.webkit\.org/show_bug\.cgi\?id=(?P<id>\d+)', re.MULTILINE)
    _trac_url_regex = re.compile(r'http(s?)://trac.webkit.org/changeset/(?P<revision>\d+)', re.MULTILINE)

    @classmethod
    def _summarize_commit_log(self, commit_log, committer_list=CommitterList()):
        patch_by = self._patch_by_regex.search(commit_log)
        commit_log = self._patch_by_regex.sub('', commit_log, count=1)

        rollout = self._rollout_regex.search(commit_log)
        commit_log = self._rollout_regex.sub('', commit_log, count=1)

        requested_by = self._requested_by_regex.search(commit_log)

        commit_log = self._bugzilla_url_regex.sub(r'https://webkit.org/b/\g<id>', commit_log)
        commit_log = self._trac_url_regex.sub(r'https://trac.webkit.org/r\g<revision>', commit_log)

        for contributor in committer_list.contributors():
            if not contributor.irc_nicknames:
                continue
            name_with_nick = "%s (%s)" % (contributor.full_name, contributor.irc_nicknames[0])
            if contributor.full_name in commit_log:
                commit_log = commit_log.replace(contributor.full_name, name_with_nick)
                for email in contributor.emails:
                    commit_log = commit_log.replace(' <' + email + '>', '')
            else:
                for email in contributor.emails:
                    commit_log = commit_log.replace(email, name_with_nick)

        lines = commit_log.split('\n')[1:-2]  # Ignore lines with ----------.

        firstline = re.match(r'^(?P<revision>r\d+) \| (?P<email>[^\|]+) \| (?P<timestamp>[^|]+) \| [^\n]+', lines[0])
        assert firstline
        author = firstline.group('email')
        if patch_by:
            author = patch_by.group('author')

        linkified_revision = 'https://trac.webkit.org/%s' % firstline.group('revision')
        lines[0] = '%s by %s' % (linkified_revision, author)

        if rollout:
            if requested_by:
                author = requested_by.group('author')
                contributor = committer_list.contributor_by_irc_nickname(author)
                if contributor:
                    author = "%s (%s)" % (contributor.full_name, contributor.irc_nicknames[0])
#.........这里部分代码省略.........
开发者ID:fmalita,项目名称:webkit,代码行数:103,代码来源:newcommitbot.py


注:本文中的webkitpy.tool.bot.ircbot.IRCBot.irc_delegate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。