Skip to content

Commit 528f23b

Browse files
authored
Merge pull request #1023 from juanjemdIos/master
cff with doi must be referencePublication instead of creditText and parse author names correctly
2 parents f71b586 + 6eedd34 commit 528f23b

3 files changed

Lines changed: 130 additions & 7 deletions

File tree

src/somef/export/json_export.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,10 @@ def format_date(date_string):
482482

483483
author_list = []
484484
for author in authors:
485-
family_name = author.get("family-names")
486-
given_name = author.get("given-names")
485+
family_name = author.get(constants.PROP_FAMILY_NAME)
486+
given_name = author.get(constants.PROP_GIVEN_NAME)
487487
orcid = author.get("orcid")
488-
name = author.get("name")
488+
name = author.get(constants.PROP_NAME)
489489

490490
if family_name and given_name:
491491
author_entry = {
@@ -806,12 +806,11 @@ def parse_contributors(raw):
806806

807807

808808
def is_scholarly_article(article_dict):
809-
if article_dict.get("type") in ["SoftwareApplication", "software"]:
810-
return False
811-
809+
812810
if article_dict.get("doi") or article_dict.get("journal"):
813811
return True
814-
812+
if article_dict.get("type") in ["SoftwareApplication", "software"]:
813+
return False
815814
if article_dict.get("type") == "ScholarlyArticle":
816815
return True
817816

src/somef/test/test_codemeta_export.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,51 @@ def test_author_organization_issue_983(self):
812812
assert author.get("email") == "sunpy@googlegroups.com", f"Expected email 'sunpy@googlegroups.com', got: {author.get('email')}"
813813

814814
os.remove(output_path)
815+
816+
817+
def test_codemeta_sunpy_reference_publication(self):
818+
"""
819+
Checks that a CITATION.cff with DOI, title and structured authors is exported as
820+
referencePublication (not creditText) in codemeta, and that individual authors
821+
are considered Person with familyName/givenName rather than @type Organization.
822+
"""
823+
output_path = test_data_path + 'test_codemeta_sunpy_refpub.json'
824+
825+
somef_cli.run_cli(threshold=0.9,
826+
ignore_classifiers=False,
827+
repo_url=None,
828+
doc_src=None,
829+
local_repo=test_data_repositories + "sunpy",
830+
in_file=None,
831+
output=None,
832+
graph_out=None,
833+
graph_format="turtle",
834+
codemeta_out=output_path,
835+
pretty=True,
836+
missing=False,
837+
requirements_mode="all")
838+
839+
with open(output_path, "r") as f:
840+
json_content = json.load(f)
841+
842+
ref_pub = json_content.get(constants.CAT_CODEMETA_REFERENCEPUBLICATION, [])
843+
# print(f"Reference publications: {ref_pub}")
844+
assert len(ref_pub) > 0, "Expected referencePublication entries"
845+
assert ref_pub[0].get("@type") == "ScholarlyArticle"
846+
847+
found_person = False
848+
for pub in ref_pub:
849+
for author in pub.get("author", []):
850+
if author.get("@type") == "Person":
851+
assert "familyName" in author
852+
assert "givenName" in author
853+
found_person = True
854+
855+
assert found_person, "No Person-type author found with familyName/givenName"
856+
857+
os.remove(output_path)
858+
859+
815860
@classmethod
816861
def tearDownClass(cls):
817862
"""delete temp file JSON just if all the test pass"""
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
cff-version: '1.1.0'
2+
message: 'Please cite the following work when using this software.'
3+
authors:
4+
- name: 'The SunPy Community'
5+
- family-names: 'Barnes'
6+
given-names: 'Will T.'
7+
- family-names: 'Bobra'
8+
given-names: 'Monica G.'
9+
- family-names: 'Christe'
10+
given-names: 'Steven D.'
11+
- family-names: 'Freij'
12+
given-names: 'Nabil'
13+
- family-names: 'Hayes'
14+
given-names: 'Laura A.'
15+
- family-names: 'Ireland'
16+
given-names: 'Jack'
17+
- family-names: 'Mumford'
18+
given-names: 'Stuart'
19+
- family-names: 'Perez-Suarez'
20+
given-names: 'David'
21+
- family-names: 'Ryan'
22+
given-names: 'Daniel F.'
23+
- family-names: 'Shih'
24+
given-names: 'Albert Y.'
25+
- family-names: 'Chanda'
26+
given-names: 'Prateek'
27+
- family-names: 'Glogowski'
28+
given-names: 'Kolja'
29+
- family-names: 'Hewett'
30+
given-names: 'Russell'
31+
- family-names: 'Hughitt'
32+
given-names: 'V. Keith'
33+
- family-names: 'Hill'
34+
given-names: 'Andrew'
35+
- family-names: 'Hiware'
36+
given-names: 'Kaustubh'
37+
- family-names: 'Inglis'
38+
given-names: 'Andrew'
39+
- family-names: 'Kirk'
40+
given-names: 'Michael S. F.'
41+
- family-names: 'Konge'
42+
given-names: 'Sudarshan'
43+
- family-names: 'Mason'
44+
given-names: 'James Paul'
45+
- family-names: 'Maloney'
46+
given-names: 'Shane Anthony'
47+
- family-names: 'Murray'
48+
given-names: 'Sophie A.'
49+
- family-names: 'Panda'
50+
given-names: 'Asish'
51+
- family-names: 'Park'
52+
given-names: 'Jongyeob'
53+
- family-names: 'Pereira'
54+
given-names: 'Tiago M. D.'
55+
- family-names: 'Reardon'
56+
given-names: 'Kevin'
57+
- family-names: 'Savage'
58+
given-names: 'Sabrina'
59+
- family-names: 'Sipőcz'
60+
given-names: 'Brigitta M.'
61+
- family-names: 'Stansby'
62+
given-names: 'David'
63+
- family-names: 'Jain'
64+
given-names: 'Yash'
65+
- family-names: 'Taylor'
66+
given-names: 'Garrison'
67+
- family-names: 'Yadav'
68+
given-names: 'Tannmay'
69+
- family-names: 'Rajul'
70+
- family-names: 'Dang'
71+
given-names: 'Trung Kien'
72+
doi: '10.3847/1538-4357/ab4f7a'
73+
identifiers:
74+
- type: 'doi'
75+
value: '10.3847/1538-4357/ab4f7a'
76+
- type: 'url'
77+
value: 'https://iopscience.iop.org/article/10.3847/1538-4357/ab4f7a'
78+
title: 'The SunPy Project: Open Source Development and Status of the Version 1.0 Core Package'
79+
url: 'https://iopscience.iop.org/article/10.3847/1538-4357/ab4f7a'

0 commit comments

Comments
 (0)