Skip to content

Commit 068dda1

Browse files
committed
feat: Add tool to validate CITATION.cff files the same way Zenodo does
1 parent 8fd451a commit 068dda1

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tools/validate_citation.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# /// script
2+
# requires-python = ">=3.13"
3+
# dependencies = [
4+
# "pyyaml",
5+
# "flask",
6+
# "idutils",
7+
# "marshmallow",
8+
# "marshmallow_utils",
9+
# "flask_resources",
10+
# "invenio_records",
11+
# "invenio_db",
12+
# "zenodo-legacy",
13+
# "zenodo-rdm",
14+
# ]
15+
#
16+
# [tool.uv.sources]
17+
# zenodo-rdm = { git = "https://github.com/zenodo/zenodo-rdm.git", subdirectory = "site", rev = "v21.0.2" }
18+
# zenodo-legacy = { git = "https://github.com/zenodo/zenodo-rdm.git", subdirectory = "legacy", rev = "v21.0.2" }
19+
# ///
20+
21+
# This script checks whether Zenodo will accept a CITATION.cff file
22+
from pathlib import Path
23+
24+
import yaml
25+
from zenodo_rdm.github.schemas import CitationMetadataSchema
26+
from zenodo_rdm.legacy.deserializers.schemas import LegacySchema
27+
28+
29+
def main() -> None:
30+
contents = Path("CITATION.cff").read_text()
31+
data = yaml.safe_load(contents)
32+
legacy_data = {"metadata": CitationMetadataSchema().load(data)}
33+
rdm_data = LegacySchema().load(legacy_data)
34+
print(rdm_data["metadata"])
35+
36+
37+
if __name__ == "__main__":
38+
main()

0 commit comments

Comments
 (0)