Coverage for src/wiktextract/extractor/de/etymology.py: 94%

12 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-21 04:53 +0000

1from wikitextprocessor import LevelNode, NodeKind 

2 

3from ...page import clean_node 

4from ...wxr_context import WiktextractContext 

5from .models import WordEntry 

6 

7 

8def extract_etymology_section( 

9 wxr: WiktextractContext, word_entry: WordEntry, level_node: LevelNode 

10) -> None: 

11 # Nested etymology bullets belong here; lists in child sections do not. 

12 for list_node in level_node.find_child(NodeKind.LIST): 

13 for list_item in list_node.find_child_recursively(NodeKind.LIST_ITEM): 

14 links: list[tuple[str, str]] = [] 

15 text = clean_node( 

16 wxr, 

17 word_entry, 

18 list( 

19 list_item.invert_find_child( 

20 NodeKind.LIST, include_empty_str=True 

21 ) 

22 ), 

23 link_collector=links, 

24 ) 

25 if text != "": 25 ↛ 13line 25 didn't jump to line 13 because the condition on line 25 was always true

26 word_entry.etymology_texts.append(text) 

27 word_entry.etymology_links.extend(links)