MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / _direct_rows

Function _direct_rows

scripts/fetch_eurlex_fulltext.py:112–128  ·  view source on GitHub ↗

Get direct children of a table (or its / ). Unlike ``table.find_all("tr")``, this does NOT recurse into nested tables, which is critical for EUR-Lex layout tables that nest sub-item tables inside outer definition rows.

(table: Tag)

Source from the content-addressed store, hash-verified

110
111
112def _direct_rows(table: Tag) -> list[Tag]:
113 """Get direct <tr> children of a table (or its <tbody>/<thead>).
114
115 Unlike ``table.find_all("tr")``, this does NOT recurse into nested
116 tables, which is critical for EUR-Lex layout tables that nest
117 sub-item tables inside outer definition rows.
118 """
119 rows: list[Tag] = []
120 for child in table.children:
121 if isinstance(child, Tag):
122 if child.name == "tr":
123 rows.append(child)
124 elif child.name in ("tbody", "thead", "tfoot"):
125 for sub in child.children:
126 if isinstance(sub, Tag) and sub.name == "tr":
127 rows.append(sub)
128 return rows
129
130
131def _is_layout_table(table: Tag) -> bool:

Callers 3

_is_layout_tableFunction · 0.85
_layout_table_to_textFunction · 0.85
_real_table_to_markdownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected