wikitextparser/_wikitext.py
def tables(self) -> List['Table']:
        """Return a list of found table objects."""
        tables = []  # type: List['Table']
        tables_append = tables.append
        type_to_spans = self._type_to_spans
        lststr = self._lststr
        shadow = self._shadow[:]
        ss, se = self._span
        spans = type_to_spans.setdefault('Table', [])
        if not spans:
            # All the added spans will be new.
            m = True  # type: Any
            while m:
                m = False
                for m in TABLE_FINDITER(shadow):
                    ms, me = m.span()
                    # Ignore leading whitespace using len(m[1]).
                    span = [ss + ms + len(m[1]), ss + me]
                    spans.append(span)
                    tables_append(Table(lststr, type_to_spans, span, 'Table'))
                    shadow[ms:me] = b'_' * (me - ms)
            return tables
        # There are already exists some spans. Try to use the already existing
        # before appending new spans.
        span_tuple_to_span_get = {(s[0], s[1]): s for s in spans}.get
        m = True
        while m:
            m = False
            for m in TABLE_FINDITER(shadow):
                ms, me = m.span()
                # Ignore leading whitespace using len(m[1]).
                s, e = ss + ms + len(m[1]), ss + me
                old_span = span_tuple_to_span_get((s, e))
                if old_span is None:
                    span = [s, e]
                    insort(spans, span)
                else:
                    span = old_span
                tables_append(Table(lststr, type_to_spans, span, 'Table'))
                shadow[ms:me] = b'_' * (me - ms)
        return tables
def tables(self) -> List['Table']:
        tables = []  # type: List['Table']
        tables_append = tables.append
        type_to_spans = self._type_to_spans
        lststr = self._lststr
        shadow = self._shadow[:]
        ss, se = self._span
        spans = type_to_spans.setdefault('Table', [])
        if not spans:
            # All the added spans will be new.
            m = True  # type: Any
            while m:
                m = False
                for m in TABLE_FINDITER(shadow):
                    ms, me = m.span()
                    # Ignore leading whitespace using len(m[1]).
                    span = [ss + ms + len(m[1]), ss + me]
                    spans.append(span)
                    tables_append(Table(lststr, type_to_spans, span, 'Table'))
                    shadow[ms:me] = b'_' * (me - ms)
            return tables
        # There are already exists some spans. Try to use the already existing
        # before appending new spans.
        span_tuple_to_span_get = {(s[0], s[1]): s for s in spans}.get
        m = True
        while m:
            m = False
            for m in TABLE_FINDITER(shadow):
                ms, me = m.span()
                # Ignore leading whitespace using len(m[1]).
                s, e = ss + ms + len(m[1]), ss + me
                old_span = span_tuple_to_span_get((s, e))
                if old_span is None:
                    span = [s, e]
                    insort(spans, span)
                else:
                    span = old_span
                tables_append(Table(lststr, type_to_spans, span, 'Table'))
                shadow[ms:me] = b'_' * (me - ms)
        return tables
def tables ( self ) -> List [ 'Table' ] : tables = [ ] # type: List['Table'] tables_append = tables . append type_to_spans = self . _type_to_spans lststr = self . _lststr shadow = self . _shadow [ : ] ss , se = self . _span spans = type_to_spans . setdefault ( 'Table' , [ ] ) if not spans : # All the added spans will be new. m = True # type: Any while m : m = False for m in TABLE_FINDITER ( shadow ) : ms , me = m . span ( ) # Ignore leading whitespace using len(m[1]). span = [ ss + ms + len ( m [ 1 ] ) , ss + me ] spans . append ( span ) tables_append ( Table ( lststr , type_to_spans , span , 'Table' ) ) shadow [ ms : me ] = b'_' * ( me - ms ) return tables # There are already exists some spans. Try to use the already existing # before appending new spans. span_tuple_to_span_get = { ( s [ 0 ] , s [ 1 ] ) : s for s in spans } . get m = True while m : m = False for m in TABLE_FINDITER ( shadow ) : ms , me = m . span ( ) # Ignore leading whitespace using len(m[1]). s , e = ss + ms + len ( m [ 1 ] ) , ss + me old_span = span_tuple_to_span_get ( ( s , e ) ) if old_span is None : span = [ s , e ] insort ( spans , span ) else : span = old_span tables_append ( Table ( lststr , type_to_spans , span , 'Table' ) ) shadow [ ms : me ] = b'_' * ( me - ms ) return tables
Return a list of found table objects.
Return a list of found table objects .