diff --git a/src/somef/export/json_export.py b/src/somef/export/json_export.py index 98714867..74778a5f 100644 --- a/src/somef/export/json_export.py +++ b/src/somef/export/json_export.py @@ -624,6 +624,15 @@ def format_date(date_string): raw_contributors = repo_data[constants.CAT_CONTRIBUTORS] codemeta_output[constants.CAT_CODEMETA_CONTRIBUTOR] = parse_contributors(raw_contributors) + if constants.CAT_APPLICATION_DOMAIN in repo_data: + application_categories = [] + for entry in repo_data[constants.CAT_APPLICATION_DOMAIN]: + value = entry[constants.PROP_RESULT][constants.PROP_VALUE] + if value not in application_categories: + application_categories.append(value) + if application_categories: + codemeta_output[constants.CAT_CODEMETA_APPLICATIONCATEGORY] = application_categories + if constants.CAT_FUNDING in repo_data: for funding_entry in repo_data[constants.CAT_FUNDING]: res_fun = funding_entry[constants.PROP_RESULT] diff --git a/src/somef/test/test_codemeta_export.py b/src/somef/test/test_codemeta_export.py index 0d0a1a54..002c5859 100644 --- a/src/somef/test/test_codemeta_export.py +++ b/src/somef/test/test_codemeta_export.py @@ -856,6 +856,32 @@ def test_codemeta_sunpy_reference_publication(self): os.remove(output_path) + def test_issue_1015_application_category(self): + """Checks that applicationCategory is present in codemeta output""" + output_path = test_data_path + 'test_application_category.json' + + somef_cli.run_cli(threshold=0.8, + ignore_classifiers=False, + repo_url=None, + local_repo=test_data_repositories + "aladin-lite", + doc_src=None, + in_file=None, + output=None, + graph_out=None, + graph_format="turtle", + codemeta_out=output_path, + pretty=True, + missing=False) + + with open(output_path, "r") as f: + json_content = json.load(f) + + assert "applicationCategory" in json_content, \ + "Missing applicationCategory in codemeta output" + assert "Astronomy, Visualization" in json_content["applicationCategory"], \ + f"Expected 'Astronomy, Visualization' in applicationCategory, got {json_content['applicationCategory']}" + + os.remove(output_path) @classmethod def tearDownClass(cls): diff --git a/src/somef/utils/constants.py b/src/somef/utils/constants.py index bec49c19..43533005 100644 --- a/src/somef/utils/constants.py +++ b/src/somef/utils/constants.py @@ -437,6 +437,7 @@ class RepositoryType(Enum): DOWNLOAD_TIMEOUT_SECONDS = 120 # CODEMETA Categories. All start with CAT_CODEMETA +CAT_CODEMETA_APPLICATIONCATEGORY = "applicationCategory" CAT_CODEMETA_AUTHOR = "author" CAT_CODEMETA_BUILDINSTRUCTIONS = "buildInstructions" CAT_CODEMETA_CODEREPOSITORY = "codeRepository"