Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/somef/export/json_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
26 changes: 26 additions & 0 deletions src/somef/test/test_codemeta_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions src/somef/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading