8000 [issue-407] write comments for relationships · spdx/tools-python@01dfeaf · GitHub
[go: up one dir, main page]

Skip to content

Commit 01dfeaf

Browse files
committed
[issue-407] write comments for relationships
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
1 parent 5538af9 commit 01dfeaf

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/spdx/writer/rdf/relationship_writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# limitations under the License.
1111
from typing import Dict
1212

13-
from rdflib import Graph, BNode, RDF, URIRef
13+
from rdflib import Graph, BNode, RDF, URIRef, RDFS, Literal
1414

1515
from spdx.model.relationship import Relationship
1616
from spdx.model.spdx_no_assertion import SpdxNoAssertion
@@ -34,7 +34,7 @@ def add_relationship_to_graph(relationship: Relationship, graph: Graph, doc_name
3434
graph.add((relationship_node, SPDX_NAMESPACE.relatedSpdxElement,
3535
URIRef(add_namespace_to_spdx_id(relationship.related_spdx_element_id, doc_namespace,
3636
external_doc_ref_to_namespace))))
37-
37+
graph.add((relationship_node, RDFS.comment, Literal(relationship.comment)))
3838
relationship_resource = URIRef(
3939
add_namespace_to_spdx_id(relationship.spdx_element_id, doc_namespace, external_doc_ref_to_namespace))
4040
graph.add((relationship_resource, SPDX_NAMESPACE.relationship, relationship_node))

tests/spdx/writer/rdf/test_relationship_writer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
11-
from rdflib import Graph, URIRef
11+
from rdflib import Graph, URIRef, RDFS, Literal
1212

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

0 commit comments

Comments
 (0)
0