]> code.ossystems Code Review - openembedded-core.git/commitdiff
spdx.py: Add annotation to relationship
authorSaul Wold <Saul.Wold@windriver.com>
Wed, 27 Oct 2021 01:30:48 +0000 (18:30 -0700)
committerAnuj Mittal <anuj.mittal@intel.com>
Tue, 2 Nov 2021 16:40:35 +0000 (00:40 +0800)
Having annotations on relationship can provide additional information
about the relationship such as how it was derived.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit d98585aa89e1d3819f8139a07fb7376ef89b37f8)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
meta/lib/oe/spdx.py

index 4416194e0622998b8ea8fca8a1d231a620cb5441..9e7ced5a155cd0954ea3fc90eb88450f37b7a618 100644 (file)
@@ -196,6 +196,7 @@ class SPDXRelationship(SPDXObject):
     relatedSpdxElement = _String()
     relationshipType = _String()
     comment = _String()
+    annotations = _ObjectList(SPDXAnnotation)
 
 
 class SPDXExternalReference(SPDXObject):
@@ -300,7 +301,7 @@ class SPDXDocument(SPDXObject):
     def from_json(cls, f):
         return cls(**json.load(f))
 
-    def add_relationship(self, _from, relationship, _to, *, comment=None):
+    def add_relationship(self, _from, relationship, _to, *, comment=None, annotation=None):
         if isinstance(_from, SPDXObject):
             from_spdxid = _from.SPDXID
         else:
@@ -320,6 +321,9 @@ class SPDXDocument(SPDXObject):
         if comment is not None:
             r.comment = comment
 
+        if annotation is not None:
+            r.annotations.append(annotation)
+
         self.relationships.append(r)
 
     def find_by_spdxid(self, spdxid):