wikitextparser/_wikilist.py
def sublists(
        self, i: int = None, pattern: str = None
    ) -> List['WikiList']:
        """Return the Lists inside the item with the given index.

        :param i: The index if the item which its sub-lists are desired.
            The performance is likely to be better if `i` is None.

        :param pattern: The starting symbol for the desired sub-lists.
            The `pattern` of the current list will be automatically added
            as prefix.
            Although this parameter is optional, but specifying it can improve
            the performance.
        """
        patterns = (r'\#', r'\*', '[:;]') if pattern is None \
            else (pattern,)  # type: Tuple[str, ...]
        self_pattern = self.pattern
        lists = self.lists
        sublists = []  # type: List['WikiList']
        sublists_append = sublists.append
        if i is None:
            # Any sublist is acceptable
            for pattern in patterns:
                for lst in lists(self_pattern + pattern):
                    sublists_append(lst)
            return sublists
        # Only return sub-lists that are within the given item
        match = self._match
        fullitem_spans = match.spans('fullitem')
        ss = self._span[0]
        ms = match.start()
        s, e = fullitem_spans[i]
        e -= ms - ss
        s -= ms - ss
        for pattern in patterns:
            for lst in lists(self_pattern + pattern):
                # noinspection PyProtectedMember
                ls, le = lst._span
                if s < ls and le <= e:
                    sublists_append(lst)
        return sublists
def sublists(
        self, i: int = None, pattern: str = None
    ) -> List['WikiList']:
        """Return the Lists inside the item with the given index.

        :param i: The index if the item which its sub-lists are desired.
            The performance is likely to be better if `i` is None.

        :param pattern: The starting symbol for the desired sub-lists.
            The `pattern` of the current list will be automatically added
            as prefix.
            Although this parameter is optional, but specifying it can improve
            the performance.
        """
        patterns = (r'\#', r'\*', '[:;]') if pattern is None \
            else (pattern,)  # type: Tuple[str, ...]
        self_pattern = self.pattern
        lists = self.lists
        sublists = []  # type: List['WikiList']
        sublists_append = sublists.append
        if i is None:
            # Any sublist is acceptable
            for pattern in patterns:
                for lst in lists(self_pattern + pattern):
                    sublists_append(lst)
            return sublists
        # Only return sub-lists that are within the given item
        match = self._match
        fullitem_spans = match.spans('fullitem')
        ss = self._span[0]
        ms = match.start()
        s, e = fullitem_spans[i]
        e -= ms - ss
        s -= ms - ss
        for pattern in patterns:
            for lst in lists(self_pattern + pattern):
                # noinspection PyProtectedMember
                ls, le = lst._span
                if s < ls and le <= e:
                    sublists_append(lst)
        return sublists
Return the Lists inside the item with the given index.

        :param i: The index if the item which its sub-lists are desired.
            The performance is likely to be better if `i` is None.

        :param pattern: The starting symbol for the desired sub-lists.
            The `pattern` of the current list will be automatically added
            as prefix.
            Although this parameter is optional, but specifying it can improve
            the performance.