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


Python Matcher.match方法代碼示例

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


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

示例1: test_regexp_matcher

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
 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,代碼行數:9,代碼來源:test_match.py

示例2: __init__

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:10,代碼來源:statistics.py

示例3: ByNameKeywordRemover

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:11,代碼來源:keywordremover.py

示例4: _SingleTagPattern

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:11,代碼來源:tags.py

示例5: ExcludeTests

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:21,代碼來源:ExcludeTests.py

示例6: _get_matches_in_iterable

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:18,代碼來源:Collections.py

示例7: _message_matches

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
 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,代碼行數:19,代碼來源:robotstatuschecker.py

示例8: _get_matches_in_iterable

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
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,代碼行數:20,代碼來源:Collections.py

示例9: test_ipy_bug_workaround

# 需要導入模塊: from robot.utils import Matcher [as 別名]
# 或者: from robot.utils.Matcher import match [as 別名]
 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,代碼行數:7,代碼來源:test_match.py


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