From 66ceeb1c406c5bb4ef1169be2143e9ae6ad6aa99 Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Mon, 9 Dec 2024 14:20:49 +0100 Subject: [PATCH 1/2] Convert version to string --- src/hermes/commands/harvest/cff.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hermes/commands/harvest/cff.py b/src/hermes/commands/harvest/cff.py index 4cc879b0..3032a31a 100644 --- a/src/hermes/commands/harvest/cff.py +++ b/src/hermes/commands/harvest/cff.py @@ -47,6 +47,7 @@ def __call__(self, command: HermesHarvestCommand) -> t.Tuple[t.Dict, t.Dict]: # Validate the content to be correct CFF cff_dict = self._load_cff_from_file(cff_data) + if command.settings.cff.enable_validation and not self._validate(cff_file, cff_dict): raise HermesValidationError(cff_file) @@ -54,6 +55,7 @@ def __call__(self, command: HermesHarvestCommand) -> t.Tuple[t.Dict, t.Dict]: codemeta_dict = self._convert_cff_to_codemeta(cff_data) # TODO Replace the following temp patch for #112 once there is a new cffconvert version with cffconvert#309 codemeta_dict = self._patch_author_emails(cff_dict, codemeta_dict) + codemeta_dict["version"] = str(codemeta_dict["version"]) # Convert Version to string return codemeta_dict, {'local_path': str(cff_file)} From d1a4bd6c1f1d36e5540817f9086eda88d023f77a Mon Sep 17 00:00:00 2001 From: "Kernchen, Sophie" Date: Thu, 19 Dec 2024 10:21:24 +0100 Subject: [PATCH 2/2] Check if version field exists --- src/hermes/commands/harvest/cff.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hermes/commands/harvest/cff.py b/src/hermes/commands/harvest/cff.py index 3032a31a..e333b27c 100644 --- a/src/hermes/commands/harvest/cff.py +++ b/src/hermes/commands/harvest/cff.py @@ -55,7 +55,8 @@ def __call__(self, command: HermesHarvestCommand) -> t.Tuple[t.Dict, t.Dict]: codemeta_dict = self._convert_cff_to_codemeta(cff_data) # TODO Replace the following temp patch for #112 once there is a new cffconvert version with cffconvert#309 codemeta_dict = self._patch_author_emails(cff_dict, codemeta_dict) - codemeta_dict["version"] = str(codemeta_dict["version"]) # Convert Version to string + if "version" in codemeta_dict: + codemeta_dict["version"] = str(codemeta_dict["version"]) # Convert Version to string return codemeta_dict, {'local_path': str(cff_file)}