loganalyzer.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:sonic-mgmt 作者: Azure 项目源码 文件源码
def line_matches(self, str, match_messages_regex, ignore_messages_regex):
        '''
        @summary: This method checks whether given string matches against the
                  set of regular expressions.

        @param str: string to match against 'match' and 'ignore' regex expressions.
            A string which matched to the 'match' set will be reported.
            A string which matches to 'match' set, but also matches to
            'ignore' set - will not be reported (will be ignored)

        @param match_messages_regex:
            regex class instance containing messages to match against.

        @param ignore_messages_regex:
            regex class instance containing messages to ignore match against.

        @return: True is str matches regex criteria, otherwise False.
        '''

        ret_code = False

        if ((match_messages_regex is not None) and (match_messages_regex.findall(str))):
            if (ignore_messages_regex is None):
                ret_code = True

            elif (not ignore_messages_regex.findall(str)):
                self.print_diagnostic_message('matching line: %s' % str)
                ret_code = True

        return ret_code
    #---------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号