Robot Framework
namepatterns.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from robot.utils import MultiMatcher
17 
18 
20 
21  def __init__(self, patterns=None):
22  self._matcher_matcher = MultiMatcher(patterns, ignore='_')
23 
24  def match(self, name, longname=None):
25  return self._match_match(name) or longname and self._match_longname_match_longname(longname)
26 
27  def _match(self, name):
28  return self._matcher_matcher.match(name)
29 
30  def _match_longname(self, name):
31  raise NotImplementedError
32 
33  def __bool__(self):
34  return bool(self._matcher_matcher)
35 
36  def __iter__(self):
37  return iter(self._matcher_matcher)
38 
39 
41 
42  def _match_longname(self, name):
43  while '.' in name:
44  if self._match_match(name):
45  return True
46  name = name.split('.', 1)[1]
47  return False
48 
49 
51 
52  def _match_longname(self, name):
53  return self._match_match(name)
def match(self, name, longname=None)
Definition: namepatterns.py:24
def __init__(self, patterns=None)
Definition: namepatterns.py:21