8000 Update spdx3.model to SPDX v3.0.1 by bact · Pull Request #829 · spdx/tools-python · GitHub
[go: up one dir, main page]

Skip to content

Update spdx3.model to SPDX v3.0.1 #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update IRI for ProfileIdentifierType
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
  • Loading branch information
bact committed Oct 9, 2024
commit 69a7a8ab6ea400cd66f8c27cb6aa3b1a1b7e2adf
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx3/bump_from_spdx2/creation_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def bump_creation_info(spdx2_creation_info: Spdx2_CreationInfo, payload: Payload
"part of licensing profile, " "https://github.com/spdx/spdx-3-model/issues/131",
)
creation_info = CreationInfo(
spec_version=Version("3.0.1"),
spec_version=Version(3, 0, 1),
created=spdx2_creation_info.created,
created_by=[],
profile=[ProfileIdentifierType.CORE, ProfileIdentifierType.SOFTWARE, ProfileIdentifierType.LICENSING],
Expand Down
2 changes: 2 additions & 0 deletions src/spdx_tools/spdx3/writer/json_ld/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 The SPDX Contributors
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx3/writer/json_ld/json_ld_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def write_payload(payload: Payload, file_name: str):

# this will be obsolete as soon as the context is publicly available under some URI
with open(os.path.join(os.path.dirname(__file__), "context.json"), "r") as infile:
context = json.load(infile)
data = json.load(infile)
context = data.get("@context")

complete_dict = {"@context": context, "@graph": element_list}

Expand Down
20 changes: 11 additions & 9 deletions src/spdx_tools/spdx3/writer/json_ld/owl_to_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,21 @@ def convert_spdx_owl_to_jsonld_context(spdx_owl: str = "SPDX_OWL.json"):
if name == "profile":
# FIXME: since the allowed values for the profile enum collide with
# our namespaces, we need to explicitly remap their meaning in the context
VERSION = "3.0.1"
PROFILE_IRI_PREFIX = f"https://spdx.org/rdf/{VERSION}/terms/Core/ProfileIdentifierType"
context_dict[name] = {
"@id": node["@id"],
"@type": "@vocab",
"@context": {
"core": "https://spdx.org/rdf/Core/ProfileIdentifierType/core",
"software": "https://spdx.org/rdf/Core/ProfileIdentifierType/software",
"licensing": "https://spdx.org/rdf/Core/ProfileIdentifierType/licensing",
"security": "https://spdx.org/rdf/Core/ProfileIdentifierType/security",
"build": "https://spdx.org/rdf/Core/ProfileIdentifierType/build",
"ai": "https://spdx.org/rdf/Core/ProfileIdentifierType/ai",
"dataset": "https://spdx.org/rdf/Core/ProfileIdentifierType/dataset",
"usage": "https://spdx.org/rdf/Core/ProfileIdentifierType/usage",
"extension": "https://spdx.org/rdf/Core/ProfileIdentifierType/extension",
"ai": f"{PROFILE_IRI_PREFIX}/ai",
"build": f"{PROFILE_IRI_PREFIX}/build",
"core": f"{PROFILE_IRI_PREFIX}/core",
"dataset": f"{PROFILE_IRI_PREFIX}/dataset",
"extension": f"{PROFILE_IRI_PREFIX}/extension",
"licensing": f"{PROFILE_IRI_PREFIX}/licensing",
"security": f"{PROFILE_IRI_PREFIX}/security",
"software": f"{PROFILE_IRI_PREFIX}/software",
"usage": f"{PROFILE_IRI_PREFIX}/usage",
},
}
else:
Expand Down
6 changes: 3 additions & 3 deletions tests/spdx3/bump/test_actor_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
def test_bump_actor(actor_type, actor_name, actor_mail, element_type, new_spdx_id):
payload = Payload()
document_namespace = "https://doc.namespace"
creation_info = CreationInfo(Version("3.0.1"), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifierType.CORE])
creation_info = CreationInfo(Version(3, 0, 1), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifierType.CORE])
actor = Actor(actor_type, actor_name, actor_mail)

agent_or_tool_id = bump_actor(actor, payload, document_namespace, creation_info)
Expand All @@ -54,8 +54,8 @@ def test_bump_actor(actor_type, actor_name, actor_mail, element_type, new_spdx_i


def test_bump_actor_that_already_exists():
creation_info_old = CreationInfo(Version("3.0.1"), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifierType.CORE])
creation_info_new = CreationInfo(Version("3.0.1"), datetime(2023, 2, 2), ["Creator"], [ProfileIdentifierType.CORE])
creation_info_old = CreationInfo(Version(3, 0, 1), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifierType.CORE])
creation_info_new = CreationInfo(Version(3, 0, 1), datetime(2023, 2, 2), ["Creator"], [ProfileIdentifierType.CORE])

name = "some name"
document_namespace = "https://doc.namespace"
Expand Down
2 changes: 1 addition & 1 deletion tests/spdx3/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@


def creation_info_fixture(
spec_version=Version("3.0.1"),
spec_version=Version(3, 0, 1),
created=datetime(2022, 12, 1),
created_by=None,
created_using=None,
Expand Down
2 changes: 1 addition & 1 deletion tests/spdx3/model/test_creation_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_correct_initialization():
for property_name in get_property_names(CreationInfo):
assert getattr(creation_info, property_name) is not None

assert creation_info.spec_version == Version("3.0.1")
assert creation_info.spec_version == Version(3, 0, 1)
assert creation_info.created == datetime(2022, 12, 1)
assert creation_info.created_by == ["https://spdx.test/tools-python/creation_info_created_by"]
assert creation_info.created_using == ["https://spdx.test/tools-python/creation_info_created_using"]
Expand Down
2 changes: 1 addition & 1 deletion tests/spdx3/writer/tag_value/test_write_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def test_render_creation_info():
fake_datetime = datetime(year=2024, month=1, day=1)
spec_version = Version("3.0.1")
spec_version = Version(3, 0, 1)
creation_info = CreationInfo(
spec_version=spec_version,
created=fake_datetime,
Expand Down
0