Coverage for src/ptf/cmds/xml/xml_base.py: 86%

22 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-05 09:56 +0000

1from ptf.cmds.xml.xml_utils import get_extid_value_from_link_data 

2from ptf.model_data import ExtLinkDict 

3from ptf.model_data import RefData 

4 

5 

6class XmlParserBase: 

7 extids: list[tuple[str, str]] = [] 

8 

9 def add_extids_from_node_with_link(self, link_data: ExtLinkDict): 

10 extid_value = get_extid_value_from_link_data(link_data) 

11 

12 if extid_value not in self.extids and extid_value[0] is not None: 

13 self.extids.append(extid_value) 

14 

15 if extid_value[0] == "doi" and self.doi is None: 

16 self.doi = extid_value[1] 

17 

18 return extid_value 

19 

20 

21class RefBase(RefData): 

22 def from_dict(self, my_dict): 

23 for key in my_dict: 

24 setattr(self, key, my_dict[key]) 

25 

26 def get_authors(self): 

27 contribs = [contrib for contrib in self.contributors if contrib["role"] == "author"] 

28 return contribs 

29 

30 def get_editors(self): 

31 contribs = [contrib for contrib in self.contributors if contrib["role"] == "editor"] 

32 return contribs