2020License related things
2121"""
2222
23+ from collections .abc import Iterable
2324from enum import Enum
2425from json import loads as json_loads
2526from typing import TYPE_CHECKING , Any , Optional , Union
3435from ..exception .model import MutuallyExclusivePropertiesException
3536from ..exception .serialization import CycloneDxDeserializationException
3637from ..schema .schema import SchemaVersion1Dot5 , SchemaVersion1Dot6 , SchemaVersion1Dot7
37- from . import AttachedText , XsUri
38+ from . import AttachedText , Property , XsUri
3839from .bom_ref import BomRef
3940
4041
@@ -85,6 +86,7 @@ def __init__(
8586 id : Optional [str ] = None , name : Optional [str ] = None ,
8687 text : Optional [AttachedText ] = None , url : Optional [XsUri ] = None ,
8788 acknowledgement : Optional [LicenseAcknowledgement ] = None ,
89+ properties : Optional [Iterable [Property ]] = None ,
8890 ) -> None :
8991 if not id and not name :
9092 raise MutuallyExclusivePropertiesException ('Either `id` or `name` MUST be supplied' )
@@ -99,6 +101,7 @@ def __init__(
99101 self ._text = text
100102 self ._url = url
101103 self ._acknowledgement = acknowledgement
104+ self ._properties = SortedSet (properties or [])
102105
103106 @property
104107 @serializable .view (SchemaVersion1Dot5 )
@@ -200,17 +203,25 @@ def url(self, url: Optional[XsUri]) -> None:
200203 # def licensing(self, ...) -> None:
201204 # ... # TODO since CDX1.5
202205
203- # @property
204- # ...
205- # @serializable.view(SchemaVersion1Dot5)
206- # @serializable.view(SchemaVersion1Dot6)
207- # @serializable.xml_sequence(6)
208- # def properties(self) -> ...:
209- # ... # TODO since CDX1.5
210- #
211- # @licensing.setter
212- # def properties(self, ...) -> None:
213- # ... # TODO since CDX1.5
206+ @property
207+ @serializable .view (SchemaVersion1Dot5 )
208+ @serializable .view (SchemaVersion1Dot6 )
209+ @serializable .view (SchemaVersion1Dot7 )
210+ @serializable .xml_array (serializable .XmlArraySerializationType .NESTED , 'property' )
211+ @serializable .xml_sequence (6 )
212+ def properties (self ) -> 'SortedSet[Property]' :
213+ """
214+ Provides the ability to document properties in a key/value store. This provides flexibility to include data not
215+ officially supported in the standard without having to use additional namespaces or create extensions.
216+
217+ Return:
218+ Set of `Property`
219+ """
220+ return self ._properties
221+
222+ @properties .setter
223+ def properties (self , properties : Iterable [Property ]) -> None :
224+ self ._properties = SortedSet (properties )
214225
215226 @property
216227 @serializable .view (SchemaVersion1Dot6 )
@@ -245,6 +256,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
245256 self ._url ,
246257 self ._text ,
247258 self ._bom_ref .value ,
259+ _ComparableTuple (self ._properties ),
248260 ))
249261
250262 def __eq__ (self , other : object ) -> bool :
0 commit comments