Coverage for src/wiktextract/extractor/de/form.py: 89%
23 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-12-27 08:07 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-12-27 08:07 +0000
1from wikitextprocessor.parser import LevelNode, NodeKind, WikiNode
3from ...page import clean_node
4from ...wxr_context import WiktextractContext
5from .models import Form, WordEntry
6from .tags import translate_raw_tags
7from .utils import extract_sense_index
10def extracrt_form_section(
11 wxr: WiktextractContext,
12 word_entry: WordEntry,
13 level_node: LevelNode,
14 tags: list[str],
15) -> None:
16 for list_item_node in level_node.find_child_recursively(NodeKind.LIST_ITEM):
17 sense_idx = ""
18 raw_tags = []
19 for child in list_item_node.children:
20 if isinstance(child, str) and child.startswith("["): 20 ↛ 21line 20 didn't jump to line 21 because the condition on line 20 was never true
21 sense_idx, _ = extract_sense_index(child)
22 elif isinstance(child, WikiNode) and child.kind == NodeKind.ITALIC:
23 raw_tag = clean_node(wxr, None, child)
24 if raw_tag.endswith(":"): 24 ↛ 19line 24 didn't jump to line 19 because the condition on line 24 was always true
25 raw_tags.append(raw_tag.removesuffix(":").strip())
26 elif isinstance(child, WikiNode) and child.kind == NodeKind.LINK:
27 form_text = clean_node(wxr, None, child)
28 if form_text != "": 28 ↛ 19line 28 didn't jump to line 19 because the condition on line 28 was always true
29 form_data = Form(
30 form=form_text,
31 tags=tags,
32 sense_index=sense_idx,
33 raw_tags=raw_tags,
34 )
35 translate_raw_tags(form_data)
36 word_entry.forms.append(form_data)