Ejemplo n.º 1
0
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)]
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._warning_or_error(kw):
            self._clear_content(kw)
Ejemplo n.º 3
0
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._warning_or_error(kw):
            self._clear_content(kw)
Ejemplo n.º 4
0
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

    def __nonzero__(self):
        return bool(self._matcher)
Ejemplo n.º 5
0
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)
    ]
Ejemplo n.º 6
0
Archivo: tags.py Proyecto: Garjy/RIDE
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

    def __nonzero__(self):
        return bool(self._matcher)
Ejemplo n.º 7
0
 def __init__(self, pattern):
     self._matcher = Matcher(pattern, ignore='_')
Ejemplo n.º 8
0
 def __init__(self, pattern):
     self._matcher = Matcher(pattern, ignore='_')
 def __init__(self, pattern):
     _KeywordRemover.__init__(self)
     self._matcher = Matcher(pattern, ignore='_')
Ejemplo n.º 10
0
 def __init__(self, pattern):
     _KeywordRemover.__init__(self)
     self._matcher = Matcher(pattern, ignore='_')