Coverage for apps/ptf/cmds/xml/xml_base.py: 87%

20 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-06-19 08:36 +0000

1from ptf.cmds.xml.xml_utils import get_extid_value_from_link_data 

2from ptf.model_data import RefData 

3 

4 

5class XmlParserBase: 

6 def add_extids_from_node_with_link(self, link_data): 

7 extid_value = get_extid_value_from_link_data(link_data) 

8 

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

10 self.extids.append(extid_value) 

11 

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

13 self.doi = extid_value[1] 

14 

15 return extid_value 

16 

17 

18class RefBase(RefData): 

19 def from_dict(self, my_dict): 

20 for key in my_dict: 

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

22 

23 def get_authors(self): 

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

25 return contribs 

26 

27 def get_editors(self): 

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

29 return contribs