@@ -13,55 +13,38 @@ def detect_citation_missing_reference_publication_pitfall(somef_data: Dict, file
1313 "citation_cff_exists" : False
1414 }
1515
16- if "citation" not in somef_data :
17- return result
18-
19- citation_entries = somef_data ["citation" ]
20- if not isinstance (citation_entries , list ):
21- return result
22-
23- codemeta_citation_value = None
24- citation_cff_citation_value = None
25- citation_cff_exists_in_somef = False
26-
27- for entry in citation_entries :
28- source = entry .get ("source" , "" )
29- technique = entry .get ("technique" , "" )
30-
31- if technique == "code_parser" and "codemeta.json" in source :
32- if "result" in entry and "value" in entry ["result" ]:
33- codemeta_citation_value = entry ["result" ]["value" ]
34- result ["codemeta_has_reference" ] = True
35- elif "CITATION.cff" in source :
36- citation_cff_exists_in_somef = True
37- result ["citation_cff_exists" ] = True
38- if "result" in entry and "value" in entry ["result" ]:
39- citation_cff_citation_value = entry ["result" ]["value" ]
40-
41- if not citation_cff_exists_in_somef :
42- citation_cff_sources = ["authors" , "title" , "description" , "version" , "license" ]
43- for category in citation_cff_sources :
44- if category in somef_data :
45- entries = somef_data [category ]
46- if isinstance (entries , list ):
47- for entry in entries :
48- source = entry .get ("source" , "" )
49- if "CITATION.cff" in source :
50- citation_cff_exists_in_somef = True
51- result ["citation_cff_exists" ] = True
52- break
53-
54- if (codemeta_citation_value and
55- citation_cff_exists_in_somef and
56- (not citation_cff_citation_value or citation_cff_citation_value != codemeta_citation_value )):
57-
58- if citation_cff_citation_value :
59- if ("doi.org" in codemeta_citation_value or "http" in codemeta_citation_value ):
60- if not ("doi.org" in citation_cff_citation_value or "http" in citation_cff_citation_value ):
61- result ["has_pitfall" ] = True
62- elif codemeta_citation_value not in citation_cff_citation_value and citation_cff_citation_value not in codemeta_citation_value :
63- result ["has_pitfall" ] = True
64- else :
65- result ["has_pitfall" ] = True
16+ if "reference_publication" in somef_data :
17+ ref_pub_entries = somef_data ["reference_publication" ]
18+ if isinstance (ref_pub_entries , list ):
19+ for entry in ref_pub_entries :
20+ source = entry .get ("source" , "" )
21+ technique = entry .get ("technique" , "" )
22+
23+ if technique == "code_parser" and "codemeta.json" in source :
24+ if "result" in entry and "value" in entry ["result" ]:
25+ result ["codemeta_has_reference" ] = True
26+
27+ elif "CITATION.cff" in source :
28+ if "result" in entry and "value" in entry ["result" ]:
29+ result ["citation_cff_has_reference" ] = True
30+
31+ citation_cff_sources = ["authors" , "title" , "description" , "version" , "license" ]
32+ for category in citation_cff_sources :
33+ if category in somef_data :
34+ entries = somef_data [category ]
35+ if isinstance (entries , list ):
36+ for entry in entries :
37+ source = entry .get ("source" , "" )
38+ if "CITATION.cff" in source :
39+ result ["citation_cff_exists" ] = True
40+ break
41+
42+ if result ["citation_cff_exists" ]:
43+ break
44+
45+ if (result ["codemeta_has_reference" ] and
46+ result ["citation_cff_exists" ] and
47+ not result ["citation_cff_has_reference" ]):
48+ result ["has_pitfall" ] = True
6649
6750 return result
0 commit comments