wikitextparser/_wikitext.py
def ancestors(self, type_: Optional[str] = None) -> List['WikiText']:
        """Return the ancestors of the current node.

        :param type_: the type of the desired ancestors as a string.
            Currently the following types are supported: {Template,
            ParserFunction, WikiLink, Comment, Parameter, ExtensionTag}.
            The default is None and means all the ancestors of any type above.
        """
        if type_ is None:
            types = SPAN_PARSER_TYPES
        else:
            types = type_,
        lststr = self._lststr
        type_to_spans = self._type_to_spans
        ss, se = self._span
        ancestors = []
        ancestors_append = ancestors.append
        for type_ in types:
            cls = globals()[type_]
            spans = type_to_spans[type_]
            for span in spans[:bisect(spans, [ss])]:
                if se < span[1]:
                    ancestors_append(cls(lststr, type_to_spans, span, type_))
        return sorted(ancestors, key=lambda i: ss - i._span[0])
def ancestors(self, type_: Optional[str] = None) -> List['WikiText']:
        if type_ is None:
            types = SPAN_PARSER_TYPES
        else:
            types = type_,
        lststr = self._lststr
        type_to_spans = self._type_to_spans
        ss, se = self._span
        ancestors = []
        ancestors_append = ancestors.append
        for type_ in types:
            cls = globals()[type_]
            spans = type_to_spans[type_]
            for span in spans[:bisect(spans, [ss])]:
                if se < span[1]:
                    ancestors_append(cls(lststr, type_to_spans, span, type_))
        return sorted(ancestors, key=lambda i: ss - i._span[0])
def ancestors ( self , type_ : Optional [ str ] = None ) -> List [ 'WikiText' ] : if type_ is None : types = SPAN_PARSER_TYPES else : types = type_ , lststr = self . _lststr type_to_spans = self . _type_to_spans ss , se = self . _span ancestors = [ ] ancestors_append = ancestors . append for type_ in types : cls = globals ( ) [ type_ ] spans = type_to_spans [ type_ ] for span in spans [ : bisect ( spans , [ ss ] ) ] : if se < span [ 1 ] : ancestors_append ( cls ( lststr , type_to_spans , span , type_ ) ) return sorted ( ancestors , key = lambda i : ss - i . _span [ 0 ] )
Return the ancestors of the current node.

        :param type_: the type of the desired ancestors as a string.
            Currently the following types are supported: {Template,
            ParserFunction, WikiLink, Comment, Parameter, ExtensionTag}.
            The default is None and means all the ancestors of any type above.
Return the ancestors of the current node .