From 72451c0d59db238a6126ae6a842bf45a5de859db Mon Sep 17 00:00:00 2001 From: Tom Morrell Date: Wed, 9 Dec 2020 10:54:03 -0800 Subject: [PATCH] metadata: Add codemeta validation --- invenio_github/api.py | 10 ++++++---- setup.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/invenio_github/api.py b/invenio_github/api.py index 6b40ff0..9df0590 100644 --- a/invenio_github/api.py +++ b/invenio_github/api.py @@ -25,7 +25,7 @@ """Invenio module that adds GitHub integration to the platform.""" import github3 -from convert_codemeta import crosswalk +from convert_codemeta import crosswalk, validate_codemeta from flask import current_app from invenio_db import db from invenio_oauth2server.models import Token as ProviderToken @@ -421,15 +421,17 @@ def extra_metadata(self): @cached_property def codemeta(self): """Get extra metadata from codemeta file in repository.""" - metadata = get_extra_metadata( + codemeta = get_extra_metadata( self.gh.api, self.repository['owner']['login'], self.repository['name'], self.release['tag_name'], 'codemeta.json' ) - return crosswalk(metadata, "codemeta", "Zenodo") - + if validate_codemeta(codemeta): + return crosswalk(codemeta, "codemeta", "Zenodo") + else: + return {} @cached_property def files(self): diff --git a/setup.py b/setup.py index 3f47112..9ea176b 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ 'Flask-Menu>=0.5.0', 'Flask>=1.0.4', 'WTForms-Alchemy>=0.15.0,<0.17', - 'convert-codemeta>=0.2.0', + 'convert-codemeta>=0.4.0', 'email-validator>=1.0.5', 'github3.py==1.0.0a4', 'humanize>=0.5.1',