Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
name: Validating CITATION.cff using 'cffconvert'

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 6.0.1
hooks:
- id: isort
name: Sorting Python import lines using 'isort'
Expand All @@ -23,7 +23,7 @@ repos:
name: Assessing the package metadata using 'pyroma'

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.278
rev: v0.11.11
hooks:
- id: ruff
name: Linting using 'ruff'
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Repository = "https://github.com/citation-file-format/cffconvert"
[project.optional-dependencies]
dev = [
"build",
"isort == 5.12.0",
"isort == 6.0.1",
"pre-commit",
"prospector == 1.10.2",
"pyroma == 4.2",
"ruff == 0.0.278"
"ruff == 0.11.11"
]
gcloud = [
"flask"
Expand Down Expand Up @@ -132,10 +132,10 @@ testpaths = [

[tool.ruff]
line-length = 120
select = ["E", "F", "W", "C901", "Q"]
lint.select = ["E", "F", "W", "C901", "Q"]

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "double"
4 changes: 1 addition & 3 deletions src/cffconvert/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from cffconvert.lib.citation import Citation


__all__ = [
"Citation"
]
__all__ = ["Citation"]
63 changes: 12 additions & 51 deletions src/cffconvert/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,21 @@
"infile": {
"type": click.Path(),
"default": None,
"help": "Path to the CITATION.cff input file. If this option is omitted" +
f", '.{os.sep}CITATION.cff' is used."
},
"outfile": {
"type": click.Path(),
"default": None,
"help": "Path to the output file."
"help": "Path to the CITATION.cff input file. If this option is omitted"
+ f", '.{os.sep}CITATION.cff' is used.",
},
"outfile": {"type": click.Path(), "default": None, "help": "Path to the output file."},
"outputformat": {
"type": click.Choice([
"apalike",
"bibtex",
"cff",
"codemeta",
"endnote",
"ris",
"schema.org",
"zenodo"
]),
"default": None,
"help": "Output format."
},
"url": {
"type": str,
"type": click.Choice(["apalike", "bibtex", "cff", "codemeta", "endnote", "ris", "schema.org", "zenodo"]),
"default": None,
"help": "URL to the CITATION.cff input file."
},
"show_help": {
"is_flag": True,
"flag_value": True,
"default": False,
"help": "Show help and exit."
},
"show_trace": {
"is_flag": True,
"flag_value": True,
"default": False,
"help": "Show error trace."
},
"validate_only": {
"is_flag": True,
"default": False,
"help": "Validate the CITATION.cff file and exit."
},
"version": {
"is_flag": True,
"default": False,
"help": "Print version and exit."
},
"verbose": {
"is_flag": True,
"default": False,
"help": "Control output verbosity."
}
"help": "Output format.",
},
"url": {"type": str, "default": None, "help": "URL to the CITATION.cff input file."},
"show_help": {"is_flag": True, "flag_value": True, "default": False, "help": "Show help and exit."},
"show_trace": {"is_flag": True, "flag_value": True, "default": False, "help": "Show error trace."},
"validate_only": {"is_flag": True, "default": False, "help": "Validate the CITATION.cff file and exit."},
"version": {"is_flag": True, "default": False, "help": "Print version and exit."},
"verbose": {"is_flag": True, "default": False, "help": "Control output verbosity."},
}
epilog = """If this program is useful to you, consider giving it a star on GitHub:
https://github.com/citation-file-format/cffconvert"""
Expand Down
4 changes: 1 addition & 3 deletions src/cffconvert/cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
GITHUB_API_VERSION_HEADER = {
"X-GitHub-Api-Version": "2022-11-28"
}
GITHUB_API_VERSION_HEADER = {"X-GitHub-Api-Version": "2022-11-28"}
2 changes: 1 addition & 1 deletion src/cffconvert/cli/rawify_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def rawify_url(url):
# Proceed with making the call without authenticating -- stricter rate limits apply
pass
else:
headers.update({"Authorization": f"Bearer { token }"})
headers.update({"Authorization": f"Bearer {token}"})

try:
response = requests.get(repos_api, headers=headers, timeout=10)
Expand Down
2 changes: 1 addition & 1 deletion src/cffconvert/cli/read_from_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def read_from_url(url):
# Proceed with making the call without authenticating -- stricter rate limits apply
pass
else:
headers.update({"Authorization": f"Bearer { token }"})
headers.update({"Authorization": f"Bearer {token}"})
response = requests.get(url_raw, headers=headers, timeout=30)
if response.ok:
return response.text
Expand Down
2 changes: 1 addition & 1 deletion src/cffconvert/cli/validate_or_write_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def validate_or_write_output(outfile, outputformat, validate_only, citation, ver
"endnote": citation.as_endnote,
"ris": citation.as_ris,
"schema.org": citation.as_schemaorg,
"zenodo": citation.as_zenodo
"zenodo": citation.as_zenodo,
}[outputformat]()
if outfile is None:
print(outstr, end="")
Expand Down
2 changes: 1 addition & 1 deletion src/cffconvert/gcloud/gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def cffconvert(request):
"endnote": citation.as_endnote,
"ris": citation.as_ris,
"schema.org": citation.as_schemaorg,
"zenodo": citation.as_zenodo
"zenodo": citation.as_zenodo,
}[outputformat]()

return Response(outstr, mimetype=mimetype_plain)
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/apalike.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


class ApalikeObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


class BibtexObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@


class Citation_1_0_x(Contract): # noqa

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def __init__(self, cffstr, cffversion):
self.cffstr = cffstr
Expand Down
1 change: 0 additions & 1 deletion src/cffconvert/lib/cff_1_0_x/codemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@


class CodemetaObject(SchemaorgObject):

def __init__(self, cffobj, context="https://doi.org/10.5063/schema/codemeta-2.0", initialize_empty=False):
super().__init__(cffobj, context=context, initialize_empty=initialize_empty)
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/endnote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


class EndnoteObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/ris.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


class RisObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/schemaorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


class SchemaorgObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def __init__(self, cffobj, context="https://schema.org", initialize_empty=False):
super().__init__(cffobj)
Expand Down
7 changes: 1 addition & 6 deletions src/cffconvert/lib/cff_1_0_x/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@


class ZenodoObject(Shared):

supported_cff_versions = [
"1.0.1",
"1.0.2",
"1.0.3"
]
supported_cff_versions = ["1.0.1", "1.0.2", "1.0.3"]

def add_contributors(self):
# contributors doesn't exist in CFF v1.0.x
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/apalike.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class ApalikeObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class BibtexObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@


class Citation_1_1_x(Contract): # noqa

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def __init__(self, cffstr, cffversion):
self.cffstr = cffstr
Expand Down
1 change: 0 additions & 1 deletion src/cffconvert/lib/cff_1_1_x/codemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@


class CodemetaObject(SchemaorgObject):

def __init__(self, cffobj, context="https://doi.org/10.5063/schema/codemeta-2.0", initialize_empty=False):
super().__init__(cffobj, context=context, initialize_empty=initialize_empty)
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/endnote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class EndnoteObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/ris.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class RisObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/schemaorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class SchemaorgObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def __init__(self, cffobj, context="https://schema.org", initialize_empty=False):
super().__init__(cffobj)
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_1_x/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@


class ZenodoObject(Shared):

supported_cff_versions = [
"1.1.0"
]
supported_cff_versions = ["1.1.0"]

def add_contributors(self):
# contributors doesn't exist in CFF v1.1.x
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_2_x/apalike.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class ApalikeObject(Shared):

supported_cff_versions = [
"1.2.0"
]
supported_cff_versions = ["1.2.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
5 changes: 1 addition & 4 deletions src/cffconvert/lib/cff_1_2_x/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@


class BibtexObject(Shared):

supported_cff_versions = [
"1.2.0"
]
supported_cff_versions = ["1.2.0"]

def add_author(self):
authors_cff = self.cffobj.get("authors", [])
Expand Down
Loading