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)
| 110 | |
| 111 | |
| 112 | def _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 | |
| 131 | def _is_layout_table(table: Tag) -> bool: |
no outgoing calls
no test coverage detected