Coverage for src / wiktextract / extractor / es / etymology.py: 93%

25 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-09 02:20 +0000

1from wikitextprocessor import LevelNode, NodeKind, TemplateNode, WikiNode 

2 

3from ...page import clean_node 

4from ...wxr_context import WiktextractContext 

5from .models import Attestation, WordEntry 

6 

7 

8def extract_etymology_section( 

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

10): 

11 missing_etymology = "Si puedes, incorpórala: ver cómo" 

12 e_nodes = [] 

13 for node in level_node.children: 

14 if isinstance(node, LevelNode): 

15 break 

16 elif isinstance(node, WikiNode) and node.kind == NodeKind.LIST: 

17 for list_item in node.find_child(NodeKind.LIST_ITEM): 

18 e_text = clean_node(wxr, base_data, list_item.children) 

19 if e_text != "" and not e_text.startswith(missing_etymology): 19 ↛ 17line 19 didn't jump to line 17 because the condition on line 19 was always true

20 base_data.etymology_texts.append(e_text) 

21 elif ( 

22 isinstance(node, TemplateNode) and node.template_name == "datación" 

23 ): 

24 date = clean_node(wxr, None, node.template_parameters.get(1, "")) 

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

26 base_data.attestations.append(Attestation(date=date)) 

27 e_nodes.append(node) 

28 else: 

29 e_nodes.append(node) 

30 

31 if len(e_nodes) > 0: 31 ↛ exitline 31 didn't return from function 'extract_etymology_section' because the condition on line 31 was always true

32 e_text = clean_node(wxr, base_data, e_nodes) 

33 if e_text != "" and not e_text.startswith(missing_etymology): 

34 base_data.etymology_texts.append(e_text)