Match tag

        :param ele:
        :type ele:
        :param tree:
        :type tree: None, list
        :return:
        :rtype: None | list
189825
def _get_tag_match(self, ele, tree):
        
        if tree in [None, []]:
            return [ele]

        res = []
        t = tree[0]
        branch = tree[1:]
        attributes = {}

        for attr in t:
            if isinstance(t[attr], dict):
                if t[attr].get("type", None) == "reg":
                    t[attr] = re.compile(t[attr]['reg'])

        attributes.update(t)

        if "name" in attributes:
            del attributes['name']
        if "text" in attributes:
            del attributes['text']
        if "recursive" in attributes:
            del attributes['recursive']
        if "[]" in attributes:
            del attributes['[]']

        possibles = ele.find_all(
            t.get('name', None),
            text=t.get('text', None),
            attrs=attributes,
            recursive=t.get('recursive', True)
        )

        if not possibles:
            return None
        else:
            pass

        if "[]" in t:
            try:
                possibles = eval("possibles[{}]".format(t["[]"]))
            except:
                # no possibles
                return None

        if not isinstance(possibles, list):
            possibles = [possibles]

        for a in possibles:
            match = self._get_tag_match(a, branch)

            if match:
                res.extend(match)

        if not res:
            return None
        else:
            return res
312148
def match(self, node, results=None):
        """"""
        if not isinstance(node, Leaf):
            return False
        return BasePattern.match(self, node, results)
1318709
def get_match(self, elem):
        """"""
        for m in self.matches:
            if (m.expression is not None and eval(m.expression)==True) \
            or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
                LOG.debug("=> match: %r" % m.expression)
                return m
1295575
def matches(self, tag, id, classes):
        
        element = self.elements[0]
        unmatched_ids = [name[1:] for name in element.names if name.startswith('#')]
        unmatched_classes = [name[1:] for name in element.names if name.startswith('.')]
        unmatched_tags = [name for name in element.names if name is not '*' and not name.startswith('#') and not name.startswith('.')]
        
        if tag and tag in unmatched_tags:
            unmatched_tags.remove(tag)

        if id and id in unmatched_ids:
            unmatched_ids.remove(id)

        for class_ in classes:
            if class_ in unmatched_classes:
                unmatched_classes.remove(class_)
        
        if unmatched_tags or unmatched_ids or unmatched_classes:
            return False

        else:
            return True
160321
def at_match(self, match, predicate=None, index=None):
        
        return self.at_span(match.span, predicate, index)
134466
function( elem, context, xml ) {
			while ( (elem = elem[ dir ]) ) {
				if ( checkNonElements || elem.nodeType === 1  ) {
					return matcher( elem, context, xml );
				}
			}
		}
527002
def _xml_element_value(el: Element, int_tags: list):
    
    # None
    if el.text is None:
        return None
    # int
    try:
        if el.tag in int_tags:
            return int(el.text)
    except:
        pass
    # default to str if not empty
    s = str(el.text).strip()
    return s if s else None
257790
def match_item(from_self, from_other)
      if Any == from_other
        true
      elsif Enumerable === from_other && Enumerable === from_self
        match_enumerable(from_self, from_other)
      else
        from_other === from_self
      end
    end
1134253
def _tag_matches(tags, filter):
        """"""
        for tag_name, tag_value in filter.items():
            # using _sentinel as I'm not sure that "None"
            # could be used, because it could be a valid
            # series_tags value : when a series has no such tag
            # then I think it's set to /null/None/.. TBC..
            series_tag_value = tags.get(tag_name, _sentinel)
            if series_tag_value != tag_value:
                return False

        return True
41896
def tag(self, text):
        
        matches = self._match(text.text)
        matches = self._resolve_conflicts(matches)

        if self.return_layer:
            return matches
        else:
            text[self.layer_name] = matches
1366468
function findSet(ele){
        for( var i = 0; i < forest.length; i++ ){
          var eles = forest[i];

          if( eles.anySame(ele) ){
            return {
              eles: eles,
              index: i
            };
          }
        }
      }
2652
def get_single_child_from_xml(elem, tag):
    
    children = elem.findall(tag)
    if not children:
        return None
    if len(children) > 1:
        logging.warning('Tag "%s" has more than one child tags with name "%s" in input file, '
                        'ignoring all but the first.',
                        elem.tag, tag)
    return children[0]
943817
def matches(match_method, *params)
      return [] unless match_method.respond_to?(:yield)
      matches = match_method.yield(*params)
      return [] unless matches.respond_to?(:each)

      # We convert Nokogiri nodes to matches transparently
      matches.map do |m|
        if m.respond_to?(:node_name)
          match(m)
        elsif m.respond_to?(:xpath)
          m.to_a.map { |n| match(n) }
        else
          m
        end
      end.flatten
    end
100776
def _remove_match(self, match):
        
        if self.__name_dict is not None:
            if match.name:
                _BaseMatches._base_remove(self._name_dict[match.name], match)
        if self.__tag_dict is not None:
            for tag in match.tags:
                _BaseMatches._base_remove(self._tag_dict[tag], match)
        if self.__start_dict is not None:
            _BaseMatches._base_remove(self._start_dict[match.start], match)
        if self.__end_dict is not None:
            _BaseMatches._base_remove(self._end_dict[match.end], match)
        if self.__index_dict is not None:
            for index in range(*match.span):
                _BaseMatches._base_remove(self._index_dict[index], match)
        if match.end >= self._max_end and not self._end_dict[match.end]:
            self._max_end = max(self._end_dict.keys())
1372338
def match(elem, seq_expr):
        
        if type(seq_expr) is str:  # wild-card
            if seq_expr == '.':  # match any element
                return True
            elif seq_expr == '\d':
                return elem.is_numerical()
            elif seq_expr == '\D':
                return not elem.is_numerical()
            else:  # invalid wild-card specified
                raise LookupError('{0} is not a valid wild-card'.format(seq_expr))
        else:  # date element
            return elem == seq_expr
29477
def match(self, item):
        
        tags = getattr(item, self._name) or []
        if self._exact:
            # Equality check
            return self._value == set(tags)
        else:
            # Is given tag in list?
            return self._value in tags
703464
def itemFromTag( self, tag ):
        
        for row in range(self.count() - 1):
            item = self.item(row)
            if ( item and item.text() == tag ):
                return item
        return None