Coverage for src/wiktextract/extractor/nl/spelling_form.py: 87%

19 statements  

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

1from wikitextprocessor import LevelNode, NodeKind, WikiNode 

2 

3from ...page import clean_node 

4from ...wxr_context import WiktextractContext 

5from .models import Form, WordEntry 

6 

7 

8def extract_spelling_form_section( 

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

10) -> None: 

11 for list_item in level_node.find_child_recursively(NodeKind.LIST_ITEM): 

12 form_nodes = [] 

13 note_str = "" 

14 for node in list_item.children: 

15 if isinstance(node, WikiNode) and node.kind == NodeKind.ITALIC: 

16 new_note_str = clean_node(wxr, None, node) 

17 if new_note_str.startswith("(") and new_note_str.endswith(")"): 17 ↛ 20line 17 didn't jump to line 20 because the condition on line 17 was always true

18 note_str = new_note_str.strip("() ") 

19 else: 

20 form_nodes.append(new_note_str) 

21 elif isinstance(node, str) or ( 21 ↛ 14line 21 didn't jump to line 14 because the condition on line 21 was always true

22 isinstance(node, WikiNode) and node.kind == NodeKind.LINK 

23 ): 

24 form_nodes.append(node) 

25 form_str = clean_node(wxr, None, form_nodes) 

26 if len(form_str) > 0: 26 ↛ 11line 26 didn't jump to line 11 because the condition on line 26 was always true

27 word_entry.forms.append(Form(form=form_str, note=note_str))