本文整理匯總了Python中robot.utils.MultiMatcher類的典型用法代碼示例。如果您正苦於以下問題:Python MultiMatcher類的具體用法?Python MultiMatcher怎麽用?Python MultiMatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MultiMatcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_include
def test_include(self):
for incl, tags in self._incl_excl_data:
builder = TagStatisticsBuilder(Criticality(), incl, [])
builder.add_test(TestCase(status='PASS', tags=tags))
matcher = MultiMatcher(incl, match_if_no_patterns=True)
expected = [tag for tag in tags if matcher.match(tag)]
assert_equal([s.name for s in builder.stats], sorted(expected))
示例2: test_exclude
def test_exclude(self):
for excl, tags in self._incl_excl_data:
builder = TagStatisticsBuilder(excluded=excl)
builder.add_test(TestCase(status='PASS', tags=tags))
matcher = MultiMatcher(excl)
expected = [tag for tag in tags if not matcher.match(tag)]
assert_equal([s.name for s in builder.stats], sorted(expected))
示例3: __init__
def __init__(self, include=None, exclude=None, combine=None, docs=None,
links=None):
self.stats = NormalizedDict(ignore=['_'])
self._include = MultiMatcher(include, ignore=['_'])
self._exclude = MultiMatcher(exclude, ignore=['_'])
self._combine = combine or []
info = TagStatInfo(docs or [], links or [])
self._get_doc = info.get_doc
self._get_links = info.get_links
示例4: FlattenKeywordMatcher
class FlattenKeywordMatcher(object):
def __init__(self, flattened):
self._types = []
names = self._yield_names_and_set_types(flattened, self._types)
self._name_matcher = MultiMatcher(names)
def _yield_names_and_set_types(self, flattened, types):
if isinstance(flattened, basestring):
flattened = [flattened]
for flat in flattened:
upper = flat.upper()
if upper in ('FOR', 'FORITEM'):
types.append(flat.lower())
elif upper.startswith('NAME:'):
yield flat[5:]
else:
raise DataError("Expected 'FOR', 'FORITEM', or "
"'NAME:<pattern>' but got '%s'." % flat)
def match_name(self, kwname, libname=None):
name = '%s.%s' % (libname, kwname) if libname else kwname
return self._name_matcher.match(name)
def match_type(self, kwtype):
return kwtype in self._types
示例5: FlattenByNameMatcher
class FlattenByNameMatcher(object):
def __init__(self, flatten):
if not is_list_like(flatten):
flatten = [flatten]
names = [n[5:] for n in flatten if n[:5].lower() == 'name:']
self._matcher = MultiMatcher(names)
def match(self, kwname, libname=None):
name = '%s.%s' % (libname, kwname) if libname else kwname
return self._matcher.match(name)
def __nonzero__(self):
return bool(self._matcher)
示例6: _NamePatterns
class _NamePatterns(object):
def __init__(self, patterns=None):
self._matcher = MultiMatcher(patterns, ignore=['_'])
def match(self, name, longname=None):
return self._match(name) or longname and self._match_longname(longname)
def _match(self, name):
return self._matcher.match(name)
def _match_longname(self, name):
raise NotImplementedError
def __nonzero__(self):
return bool(self._matcher)
示例7: FlattenKeywordMatcher
class FlattenKeywordMatcher(object):
def __init__(self, flattened):
self._types = []
names = self._yield_names_and_set_types(flattened, self._types)
self._name_matcher = MultiMatcher(names)
def _yield_names_and_set_types(self, flattened, types):
if isinstance(flattened, string_types):
flattened = [flattened]
for flat in flattened:
upper = flat.upper()
if upper in ("FOR", "FORITEM"):
types.append(flat.lower())
elif upper.startswith("NAME:"):
yield flat[5:]
else:
raise DataError("Expected 'FOR', 'FORITEM', or " "'NAME:<pattern>' but got '%s'." % flat)
def match(self, name, type):
return self._name_matcher.match(name) or type in self._types
示例8: search
def search(self, patterns):
matcher = MultiMatcher(patterns, match_if_no_patterns=True)
for kw in self._keywords:
if matcher.match(kw.name):
yield kw
示例9: __init__
def __init__(self, flatten):
if not is_list_like(flatten):
flatten = [flatten]
names = [n[5:] for n in flatten if n[:5].lower() == 'name:']
self._matcher = MultiMatcher(names)
示例10: test_regexp_match_any
def test_regexp_match_any(self):
matcher = MultiMatcher(['H.llo', 'w.*'], regexp=True)
assert matcher.match_any(('Hi', 'world'))
assert matcher.match_any(['jam', 'is', 'hillo'])
assert not matcher.match_any(('no', 'match', 'here'))
assert not matcher.match_any(())
示例11: test_match_any
def test_match_any(self):
matcher = MultiMatcher(['H?llo', 'w*'])
assert matcher.match_any(('Hi', 'world'))
assert matcher.match_any(['jam', 'is', 'hillo'])
assert not matcher.match_any(('no', 'match', 'here'))
assert not matcher.match_any(())
示例12: test_match_regexp_pattern
def test_match_regexp_pattern(self):
matcher = MultiMatcher(['xxx', 'f.*'], ignore='_:', regexp=True)
assert matcher.match('xxx')
assert matcher.match('foo')
assert matcher.match('__::FOO::__')
assert not matcher.match('bar')
示例13: test_match_pattern
def test_match_pattern(self):
matcher = MultiMatcher(['xxx', 'f*'], ignore='.:')
assert matcher.match('xxx')
assert matcher.match('foo')
assert matcher.match('..::FOO::..')
assert not matcher.match('bar')
示例14: __init__
def __init__(self, flattened):
self._types = []
names = self._yield_names_and_set_types(flattened, self._types)
self._name_matcher = MultiMatcher(names)
示例15: __init__
def __init__(self, patterns=None):
self._matcher = MultiMatcher(patterns, ignore=['_'])