Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle message output in Zenodo and bibtex backends #385

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/cffconvert/lib/cff_1_x_x/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, cffobj, initialize_empty=False):
self.title = None
self.url = None
self.year = None
self.note = None
if initialize_empty:
# clause for testing purposes
pass
Expand All @@ -26,7 +27,8 @@ def __str__(self):
self.month,
self.title,
self.url,
self.year] if item is not None]
self.year,
self.note] if item is not None]
joined = ",\n".join(items)
return "@misc{YourReferenceHere,\n" + joined + "\n}\n"

Expand All @@ -36,7 +38,8 @@ def add_all(self):
.add_month() \
.add_title() \
.add_url() \
.add_year()
.add_year() \
.add_note()
return self

@abstractmethod
Expand Down Expand Up @@ -64,6 +67,11 @@ def add_url(self):
def add_year(self):
pass

def add_note(self):
if "message" in self.cffobj:
self.note = "note = {" + self.cffobj["message"] + "}"
return self

def as_string(self):
return str(self)

Expand Down
8 changes: 8 additions & 0 deletions src/cffconvert/lib/cff_1_x_x/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self, cffobj, initialize_empty=False):
self.contributors = None
self.creators = None
self.description = None
self.additional_descriptions = None
self.keywords = None
self.license = None
self.publication_date = None
Expand All @@ -30,6 +31,7 @@ def __str__(self, sort_keys=True, indent=2):
"contributors": self.contributors,
"creators": self.creators,
"description": self.description,
"additional_descriptions": self.additional_descriptions,
"keywords": self.keywords,
"license": self.license,
"publication_date": self.publication_date,
Expand All @@ -45,6 +47,7 @@ def add_all(self):
self.add_contributors() \
.add_creators() \
.add_description() \
.add_additional_descriptions() \
.add_keywords() \
.add_license() \
.add_publication_date() \
Expand All @@ -66,6 +69,11 @@ def add_description(self):
self.description = self.cffobj.get("abstract")
return self

def add_additional_descriptions(self):
if "message" in self.cffobj:
self.additional_descriptions = [ { "type": { "id": "notes"} , "description": self.cffobj.get("message") } ]
return self

def add_keywords(self):
self.keywords = self.cffobj.get("keywords")
return self
Expand Down
8 changes: 8 additions & 0 deletions tests/cli/cff_1_0_3/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/cff_1_0_3/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/cli/cff_1_1_0/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/cff_1_1_0/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/cli/cff_1_2_0/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "test for constructing dois",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"name": "Test author"
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/cff_1_2_0/bibtex.bib
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@misc{YourReferenceHere,
author = {{Test author}},
doi = {10.0000/from-doi},
title = {Test title}
title = {Test title},
note = {test for constructing dois}
}
8 changes: 8 additions & 0 deletions tests/cli/cff_1_3_0/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "test for constructing dois",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"name": "Test author"
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/cff_1_3_0/bibtex.bib
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@misc{YourReferenceHere,
author = {{Test author}},
doi = {10.0000/from-doi},
title = {Test title}
title = {Test title},
note = {test for constructing dois}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_0_3/a/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_0_3/a/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_0_3/b/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "Example data from the CITATION.cff spec 1.0.3",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"name": "Fernández de Córdoba Jr., Gonzalo"
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_0_3/b/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ @misc{YourReferenceHere
author = {Fernández de Córdoba Jr., Gonzalo},
month = {12},
title = {example title},
year = {1999}
year = {1999},
note = {Example data from the CITATION.cff spec 1.0.3}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_0_3/c/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_0_3/c/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {10},
title = {spot},
url = {https://github.com/NLeSC/spot},
year = {2017}
year = {2017},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_0_3/d/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_0_3/d/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {7},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_0_3/e/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_0_3/e/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {5},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/a/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/a/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/b/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/b/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/c/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/c/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/d/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/d/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/e/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/e/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
8 changes: 8 additions & 0 deletions tests/lib/cff_1_1_0/f/.zenodo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"additional_descriptions": [
{
"description": "If you use this software, please cite it using these metadata.",
"type": {
"id": "notes"
}
}
],
"creators": [
{
"affiliation": "Netherlands eScience Center",
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/cff_1_1_0/f/bibtex.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ @misc{YourReferenceHere
month = {1},
title = {cffconvert},
url = {https://github.com/citation-file-format/cffconvert},
year = {2018}
year = {2018},
note = {If you use this software, please cite it using these metadata.}
}
Loading