當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.Matcher類代碼示例

本文整理匯總了Python中robot.utils.Matcher的典型用法代碼示例。如果您正苦於以下問題:Python Matcher類的具體用法?Python Matcher怎麽用?Python Matcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Matcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_regexp_matcher

 def test_regexp_matcher(self):
     matcher = Matcher('F .*', ignore=['-'], caseless=False, spaceless=True,
                       regexp=True)
     assert matcher.pattern == 'F .*'
     assert matcher.match('Foo')
     assert matcher.match('--Foo')
     assert not matcher.match('foo')
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:7,代碼來源:test_match.py

示例2: _get_matches_in_iterable

def _get_matches_in_iterable(iterable, pattern, case_insensitive=False,
                             whitespace_insensitive=False):
    if not is_string(pattern):
        raise TypeError("Pattern must be string, got '%s'." % type_name(pattern))
    regexp = False
    if pattern.startswith('regexp='):
        pattern = pattern[7:]
        regexp = True
    elif pattern.startswith('glob='):
        pattern = pattern[5:]
    matcher = Matcher(pattern,
                      caseless=is_truthy(case_insensitive),
                      spaceless=is_truthy(whitespace_insensitive),
                      regexp=regexp)
    return [string for string in iterable
            if is_string(string) and matcher.match(string)]
開發者ID:toonst,項目名稱:robotframework,代碼行數:16,代碼來源:Collections.py

示例3: _message_matches

 def _message_matches(self, actual, expected):
     if actual == expected:
         return True
     if expected.startswith('REGEXP:'):
         pattern = '^%s$' % expected.replace('REGEXP:', '', 1).strip()
         if re.match(pattern, actual, re.DOTALL):
             return True
     if expected.startswith('GLOB:'):
         pattern = expected.replace('GLOB:', '', 1).strip()
         matcher = Matcher(pattern, caseless=False, spaceless=False)
         if matcher.match(actual):
             return True
     if expected.startswith('STARTS:'):
         start = expected.replace('STARTS:', '', 1).strip()
         if actual.startswith(start):
             return True
     return False
開發者ID:robotframework,項目名稱:statuschecker,代碼行數:17,代碼來源:robotstatuschecker.py

示例4: __init__

class TagStatDoc:

    def __init__(self, pattern, doc):
        self.text = doc
        self._matcher = Matcher(pattern, ignore=['_'])

    def matches(self, tag):
        return self._matcher.match(tag)
開發者ID:AppsFuel,項目名稱:sublime-robot-plugin,代碼行數:8,代碼來源:statistics.py

示例5: ByNameKeywordRemover

class ByNameKeywordRemover(_KeywordRemover):

    def __init__(self, pattern):
        _KeywordRemover.__init__(self)
        self._matcher = Matcher(pattern, ignore='_')

    def start_keyword(self, kw):
        if self._matcher.match(kw.name) and not self._contains_warning(kw):
            self._clear_content(kw)
開發者ID:frameworks-alexuser01,項目名稱:robotframework,代碼行數:9,代碼來源:keywordremover.py

示例6: _SingleTagPattern

class _SingleTagPattern(object):
    def __init__(self, pattern):
        self._matcher = Matcher(pattern, ignore=["_"])

    def match(self, tags):
        return any(self._matcher.match(tag) for tag in tags)

    def __unicode__(self):
        return self._matcher.pattern
開發者ID:nagyist,項目名稱:RIDE,代碼行數:9,代碼來源:tags.py

示例7: _get_matches_in_iterable

def _get_matches_in_iterable(iterable, pattern, case_insensitive=False,
                             whitespace_insensitive=False):
    if not iterable:
        return []
    regexp = False
    if not isinstance(pattern, basestring):
        raise TypeError(
            "Pattern must be string, got '%s'." % type(pattern).__name__)
    if pattern.startswith('regexp='):
        pattern = pattern[7:]
        regexp = True
    elif pattern.startswith('glob='):
        pattern = pattern[5:]
    matcher = Matcher(pattern, caseless=case_insensitive,
                      spaceless=whitespace_insensitive, regexp=regexp)
    return [string for string in iterable
            if isinstance(string, basestring)
            and matcher.match(string)]
開發者ID:caseyding,項目名稱:robotframework,代碼行數:18,代碼來源:Collections.py

示例8: _SingleTagPattern

class _SingleTagPattern(object):

    def __init__(self, pattern):
        self._matcher = Matcher(pattern, ignore='_')

    def match(self, tags):
        return self._matcher.match_any(tags)

    def __unicode__(self):
        return self._matcher.pattern
開發者ID:agalitz,項目名稱:robotframework,代碼行數:10,代碼來源:tags.py

示例9: ExcludeTests

class ExcludeTests(SuiteVisitor):

    def __init__(self, pattern):
        self.matcher = Matcher(pattern)

    def start_suite(self, suite):
        """Remove tests that match the given pattern."""
        suite.tests = [t for t in suite.tests if not self._is_excluded(t)]

    def _is_excluded(self, test):
        return self.matcher.match(test.name) or self.matcher.match(test.longname)

    def end_suite(self, suite):
        """Remove suites that are empty after removing tests."""
        suite.suites = [s for s in suite.suites if s.test_count > 0]

    def visit_test(self, test):
        """Avoid visiting tests and their keywords to save a little time."""
        pass
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:19,代碼來源:ExcludeTests.py

示例10: _SingleTagPattern

class _SingleTagPattern(object):

    def __init__(self, pattern):
        self._matcher = Matcher(pattern, ignore='_')

    def match(self, tags):
        return self._matcher.match_any(tags)

    # FIXME: Why only this class methods below??
    def __unicode__(self):
        return self._matcher.pattern

    def __nonzero__(self):
        return bool(self._matcher)
開發者ID:moto-timo,項目名稱:robotframework,代碼行數:14,代碼來源:tags.py

示例11: SingleTagPattern

class SingleTagPattern(object):

    def __init__(self, pattern):
        self._matcher = Matcher(pattern, ignore='_')

    def match(self, tags):
        return self._matcher.match_any(tags)

    def __iter__(self):
        yield self

    def __unicode__(self):
        return self._matcher.pattern

    def __nonzero__(self):
        return bool(self._matcher)
開發者ID:mohzah,項目名稱:robotframework,代碼行數:16,代碼來源:tags.py

示例12: __init__

 def __init__(self, pattern):
     _KeywordRemover.__init__(self)
     self._matcher = Matcher(pattern, ignore='_')
開發者ID:frameworks-alexuser01,項目名稱:robotframework,代碼行數:3,代碼來源:keywordremover.py

示例13: test_regexp_match_any

 def test_regexp_match_any(self):
     matcher = Matcher('H.llo', regexp=True)
     assert matcher.match_any(('Hello', 'world'))
     assert matcher.match_any(['jam', 'is', 'hillo'])
     assert not matcher.match_any(('no', 'match', 'here'))
     assert not matcher.match_any(())
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:6,代碼來源:test_match.py

示例14: test_ipy_bug_workaround

 def test_ipy_bug_workaround(self):
     # https://github.com/IronLanguages/ironpython2/issues/515
     matcher = Matcher("'12345678901234567890'")
     assert matcher.match("'12345678901234567890'")
     assert not matcher.match("'xxx'")
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:5,代碼來源:test_match.py

示例15: __init__

 def __init__(self, pattern):
     self.matcher = Matcher(pattern)
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:2,代碼來源:ExcludeTests.py


注:本文中的robot.utils.Matcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。