Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/spdx/writer/rdf/relationship_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# limitations under the License.
from typing import Dict

from rdflib import Graph, BNode, RDF, URIRef
from rdflib import Graph, BNode, RDF, URIRef, RDFS, Literal

from spdx.model.relationship import Relationship
from spdx.model.spdx_no_assertion import SpdxNoAssertion
Expand All @@ -34,7 +34,7 @@ def add_relationship_to_graph(relationship: Relationship, graph: Graph, doc_name
graph.add((relationship_node, SPDX_NAMESPACE.relatedSpdxElement,
URIRef(add_namespace_to_spdx_id(relationship.related_spdx_element_id, doc_namespace,
external_doc_ref_to_namespace))))

graph.add((relationship_node, RDFS.comment, Literal(relationship.comment)))
relationship_resource = URIRef(
add_namespace_to_spdx_id(relationship.spdx_element_id, doc_namespace, external_doc_ref_to_namespace))
graph.add((relationship_resource, SPDX_NAMESPACE.relationship, relationship_node))
3 changes: 2 additions & 1 deletion tests/spdx/writer/rdf/test_relationship_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from rdflib import Graph, URIRef
from rdflib import Graph, URIRef, RDFS, Literal

from spdx.writer.rdf.relationship_writer import add_relationship_to_graph
from spdx.rdfschema.namespace import SPDX_NAMESPACE
Expand All @@ -23,3 +23,4 @@ def test_add_relationship_to_graph():
assert(URIRef("docNamespace#SPDXRef-DOCUMENT"), SPDX_NAMESPACE.relationship, None) in graph
assert (None, SPDX_NAMESPACE.relationshipType, SPDX_NAMESPACE.relationshipType_describes) in graph
assert (None, SPDX_NAMESPACE.relatedSpdxElement, URIRef("docNamespace#SPDXRef-File")) in graph
assert (None, RDFS.comment, Literal(relationship.comment)) in graph