MCPcopy Index your code
hub / github.com/clips/pattern / tables

Method tables

pattern/web/__init__.py:1849–1875  ·  view source on GitHub ↗

Yields a list of MediaWikiTable objects in the section.

(self)

Source from the content-addressed store, hash-verified

1847
1848 @property
1849 def tables(self):
1850 """ Yields a list of MediaWikiTable objects in the section.
1851 """
1852 if self._tables is None:
1853 self._tables = []
1854 b = "<table class=\"wikitable\"", "</table>"
1855 p = self.article._plaintext
1856 f = find_between
1857 for s in f(b[0], b[1], self.source):
1858 t = self.article.parser.MediaWikiTable(self,
1859 title = p((f(r"<caption.*?>", "</caption>", s) + [""])[0]),
1860 source = b[0] + s + b[1]
1861 )
1862 for i, row in enumerate(f(r"<tr", "</tr>", s)):
1863 # 1) Parse <td> and <th> content and format it as plain text.
1864 # 2) Parse <td colspan=""> attribute, duplicate spanning cells.
1865 # 3) For <th> in the first row, update MediaWikiTable.headers.
1866 r1 = f(r"<t[d|h]", r"</t[d|h]>", row)
1867 r1 = (((f(r'colspan="', r'"', v)+[1])[0], v[v.find(">")+1:]) for v in r1)
1868 r1 = ((int(n), v) for n, v in r1)
1869 r2 = []; [[r2.append(p(v)) for j in range(n)] for n, v in r1]
1870 if i == 0 and "</th>" in row:
1871 t.headers = r2
1872 else:
1873 t.rows.append(r2)
1874 self._tables.append(t)
1875 return self._tables
1876
1877 @property
1878 def level(self):

Callers

nothing calls this directly

Calls 5

fFunction · 0.85
pFunction · 0.85
MediaWikiTableMethod · 0.45
findMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected