Coverage for src/wiktextract/extractor/tr/etymology.py: 93%
18 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-07 00:55 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-07 00:55 +0000
1from wikitextprocessor.parser import LEVEL_KIND_FLAGS, LevelNode, NodeKind
3from ...page import clean_node
4from ...wxr_context import WiktextractContext
5from .models import WordEntry
8def extract_etymology_section(
9 wxr: WiktextractContext, base_data: WordEntry, level_node: LevelNode
10) -> None:
11 for list_node in level_node.find_child(NodeKind.LIST):
12 for list_item in list_node.find_child(NodeKind.LIST_ITEM):
13 links: list[tuple[str, str]] = []
14 e_str = clean_node(
15 wxr, base_data, list_item.children, link_collector=links
16 )
17 if e_str != "": 17 ↛ 12line 17 didn't jump to line 12 because the condition on line 17 was always true
18 base_data.etymology_texts.append(e_str)
19 base_data.etymology_links.extend(links)
20 if len(base_data.etymology_texts) == 0:
21 links = []
22 e_str = clean_node(
23 wxr,
24 base_data,
25 list(
26 level_node.invert_find_child(
27 LEVEL_KIND_FLAGS, include_empty_str=True
28 )
29 ),
30 link_collector=links,
31 )
32 if e_str != "": 32 ↛ exitline 32 didn't return from function 'extract_etymology_section' because the condition on line 32 was always true
33 base_data.etymology_texts.append(e_str)
34 base_data.etymology_links.extend(links)