Skip to content

Commit

Permalink
github: add default license from Github API
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo authored and slint committed Nov 28, 2024
1 parent 5a2ee37 commit d93d514
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions site/zenodo_rdm/github/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from invenio_github.errors import CustomGitHubMetadataError
from invenio_rdm_records.services.github.metadata import RDMReleaseMetadata
from invenio_rdm_records.services.github.release import RDMGithubRelease

from zenodo_rdm.github.schemas import CitationMetadataSchema
from zenodo_rdm.legacy.deserializers.schemas import LegacySchema

Expand All @@ -28,7 +27,10 @@ def load_extra_metadata(self):
if not content:
# File does not exists
return {}
legacy_data = {"metadata": json.loads(content.decoded.decode("utf-8"))}
file_data = json.loads(content.decoded.decode("utf-8"))
if not file_data.get("license") and self.repo_license:
file_data.update({"license": self.repo_license})
legacy_data = {"metadata": file_data}
rdm_data = LegacySchema().load(legacy_data)
return rdm_data["metadata"]
except Exception as exc:
Expand All @@ -51,6 +53,8 @@ def load_citation_metadata(self, data):
)

try:
if not data.get("license") and self.repo_license:
data.update({"license": self.repo_license})
legacy_data = {"metadata": CitationMetadataSchema().load(data)}
rdm_data = LegacySchema().load(legacy_data)
return rdm_data["metadata"]
Expand Down Expand Up @@ -105,4 +109,7 @@ def metadata(self):
]
}
)
# Add default license if not yet added
if not output.get("rights"):
output.update({"rights": [{"id": metadata.repo_license or "cc-by-4.0"}]})
return output

0 comments on commit d93d514

Please sign in to comment.