Coverage for src/wiktextract/extractor/ko/etymology.py: 97%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-12-27 08:07 +0000

1from wikitextprocessor.parser import LEVEL_KIND_FLAGS, 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 if len(word_entry.etymology_texts) > 0: 

12 word_entry.etymology_texts.clear() 

13 word_entry.categories.clear() 

14 

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

16 for list_item in list_node.find_child(NodeKind.LIST_ITEM): 

17 text = clean_node(wxr, word_entry, list_item.children) 

18 if len(text) > 0: 18 ↛ 16line 18 didn't jump to line 16 because the condition on line 18 was always true

19 word_entry.etymology_texts.append(text) 

20 

21 if len(word_entry.etymology_texts) == 0: # no list 

22 text = clean_node( 

23 wxr, 

24 word_entry, 

25 list(level_node.invert_find_child(LEVEL_KIND_FLAGS)), 

26 ) 

27 if len(text) > 0: 

28 word_entry.etymology_texts.append(text)