Coverage for src/wiktextract/extractor/id/etymology.py: 93%
20 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,
10 word_entry: WordEntry,
11 level_node: LevelNode,
12) -> None:
13 has_list = False
14 for list_node in level_node.find_child(NodeKind.LIST):
15 has_list = True
16 for list_item in list_node.find_child(NodeKind.LIST_ITEM):
17 e_links: list[tuple[str, str]] = []
18 e_str = clean_node(
19 wxr, word_entry, list_item.children, link_collector=e_links
20 )
21 if e_str != "": 21 ↛ 16line 21 didn't jump to line 16 because the condition on line 21 was always true
22 word_entry.etymology_texts.append(e_str)
23 word_entry.etymology_links.extend(e_links)
24 if not has_list:
25 e_links: list[tuple[str, str]] = []
26 e_str = clean_node(
27 wxr,
28 word_entry,
29 list(
30 level_node.invert_find_child(
31 LEVEL_KIND_FLAGS, include_empty_str=True
32 )
33 ),
34 link_collector=e_links,
35 )
36 if e_str != "": 36 ↛ exitline 36 didn't return from function 'extract_etymology_section' because the condition on line 36 was always true
37 word_entry.etymology_texts.append(e_str)
38 word_entry.etymology_links.extend(e_links)