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
1 change: 1 addition & 0 deletions docs/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ The table below summarizes the mapping between the SOMEF internal JSON structure

| Codemeta / Schema.org Field | SOMEF Category | Description |
| :--- | :--- | :--- |
| `applicationCategory` | `application_domain` | Categories |
| `author` | `author` | Principal authors |
| `buildInstructions` | `installation` / `documentation` | Installation or build instructions |
| `creditText` | `citation` (Software) | Human-readable citation for the software *1*|
Expand Down
7 changes: 7 additions & 0 deletions src/somef/export/json_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ def format_date(date_string):
if status:
codemeta_output[constants.CAT_CODEMETA_DEVELOPMENTSTATUS] = status

if constants.CAT_APPLICATION_DOMAIN in repo_data:
codemeta_output[constants.CAT_CODEMETA_APPLICATIONCATEGORY] = []
for domain in repo_data[constants.CAT_APPLICATION_DOMAIN]:
value = domain[constants.PROP_RESULT][constants.PROP_VALUE]
if value not in codemeta_output[constants.CAT_CODEMETA_APPLICATIONCATEGORY]:
codemeta_output[constants.CAT_CODEMETA_APPLICATIONCATEGORY].append(value)

if constants.CAT_IDENTIFIER in repo_data:
codemeta_output[constants.CAT_CODEMETA_IDENTIFIER] = []

Expand Down
32 changes: 32 additions & 0 deletions src/somef/test/test_codemeta_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,38 @@ def test_author_organization_issue_983(self):
assert author.get("email") == "sunpy@googlegroups.com", f"Expected email 'sunpy@googlegroups.com', got: {author.get('email')}"

os.remove(output_path)


def test_issue_544(self):
"""Checks whether application domain is correctly exported to applicationCategory in codemeta"""

somef_cli.run_cli(threshold=0.8,
ignore_classifiers=False,
repo_url=None,
local_repo=test_data_repositories + "Widoco",
doc_src=None,
in_file=None,
output=None,
graph_out=None,
graph_format="turtle",
codemeta_out=test_data_path + "test_issue_544.json",
pretty=True,
missing=False,
readme_only=False)

text_file = open(test_data_path + "test_issue_544.json", "r")
data = text_file.read()
text_file.close()
json_content = json.loads(data)

applicationCategory = json_content[constants.CAT_CODEMETA_APPLICATIONCATEGORY]

assert constants.CAT_CODEMETA_APPLICATIONCATEGORY in json_content
applicationCategory = json_content[constants.CAT_CODEMETA_APPLICATIONCATEGORY]
assert isinstance(applicationCategory, list)
assert "Semantic web" in applicationCategory

os.remove(test_data_path + "test_issue_544.json")
@classmethod
def tearDownClass(cls):
"""delete temp file JSON just if all the test pass"""
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