24
24
25
25
from .._internal .bom_ref import bom_ref_from_str as _bom_ref_from_str
26
26
from .._internal .compare import ComparableTuple as _ComparableTuple
27
- from ..schema .schema import SchemaVersion1Dot6
27
+ from ..schema .schema import SchemaVersion1Dot5 , SchemaVersion1Dot6
28
28
from . import XsUri
29
29
from .bom_ref import BomRef
30
30
@@ -49,7 +49,7 @@ def __init__(
49
49
postal_code : Optional [str ] = None ,
50
50
street_address : Optional [str ] = None ,
51
51
) -> None :
52
- self ._bom_ref = _bom_ref_from_str (bom_ref , optional = True )
52
+ self ._bom_ref = _bom_ref_from_str (bom_ref )
53
53
self .country = country
54
54
self .region = region
55
55
self .locality = locality
@@ -58,11 +58,11 @@ def __init__(
58
58
self .street_address = street_address
59
59
60
60
@property
61
- @serializable .json_name ('bom-ref' )
62
61
@serializable .type_mapping (BomRef )
63
62
@serializable .xml_attribute ()
64
63
@serializable .xml_name ('bom-ref' )
65
- def bom_ref (self ) -> Optional [BomRef ]:
64
+ @serializable .json_name ('bom-ref' )
65
+ def bom_ref (self ) -> BomRef :
66
66
"""
67
67
An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
68
68
unique within the BOM.
@@ -167,7 +167,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
167
167
self .country , self .region , self .locality , self .postal_code ,
168
168
self .post_office_box_number ,
169
169
self .street_address ,
170
- None if self .bom_ref is None else self . bom_ref .value ,
170
+ self ._bom_ref .value ,
171
171
))
172
172
173
173
def __eq__ (self , other : object ) -> bool :
@@ -199,14 +199,33 @@ class OrganizationalContact:
199
199
200
200
def __init__ (
201
201
self , * ,
202
+ bom_ref : Optional [Union [str , BomRef ]] = None ,
202
203
name : Optional [str ] = None ,
203
204
phone : Optional [str ] = None ,
204
205
email : Optional [str ] = None ,
205
206
) -> None :
207
+ self ._bom_ref = _bom_ref_from_str (bom_ref )
206
208
self .name = name
207
209
self .email = email
208
210
self .phone = phone
209
211
212
+ @property
213
+ @serializable .view (SchemaVersion1Dot5 )
214
+ @serializable .view (SchemaVersion1Dot6 )
215
+ @serializable .type_mapping (BomRef )
216
+ @serializable .xml_attribute ()
217
+ @serializable .xml_name ('bom-ref' )
218
+ @serializable .json_name ('bom-ref' )
219
+ def bom_ref (self ) -> BomRef :
220
+ """
221
+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
222
+ unique within the BOM.
223
+
224
+ Returns:
225
+ `BomRef`
226
+ """
227
+ return self ._bom_ref
228
+
210
229
@property
211
230
@serializable .xml_sequence (1 )
212
231
@serializable .xml_string (serializable .XmlStringSerializationType .NORMALIZED_STRING )
@@ -257,7 +276,8 @@ def phone(self, phone: Optional[str]) -> None:
257
276
258
277
def __comparable_tuple (self ) -> _ComparableTuple :
259
278
return _ComparableTuple ((
260
- self .name , self .email , self .phone
279
+ self .name , self .email , self .phone ,
280
+ self ._bom_ref .value ,
261
281
))
262
282
263
283
def __eq__ (self , other : object ) -> bool :
@@ -289,16 +309,35 @@ class OrganizationalEntity:
289
309
290
310
def __init__ (
291
311
self , * ,
312
+ bom_ref : Optional [Union [str , BomRef ]] = None ,
292
313
name : Optional [str ] = None ,
293
314
urls : Optional [Iterable [XsUri ]] = None ,
294
315
contacts : Optional [Iterable [OrganizationalContact ]] = None ,
295
316
address : Optional [PostalAddress ] = None ,
296
317
) -> None :
318
+ self ._bom_ref = _bom_ref_from_str (bom_ref )
297
319
self .name = name
298
320
self .address = address
299
321
self .urls = urls or []
300
322
self .contacts = contacts or []
301
323
324
+ @property
325
+ @serializable .view (SchemaVersion1Dot5 )
326
+ @serializable .view (SchemaVersion1Dot6 )
327
+ @serializable .type_mapping (BomRef )
328
+ @serializable .xml_attribute ()
329
+ @serializable .xml_name ('bom-ref' )
330
+ @serializable .json_name ('bom-ref' )
331
+ def bom_ref (self ) -> BomRef :
332
+ """
333
+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
334
+ unique within the BOM.
335
+
336
+ Returns:
337
+ `BomRef`
338
+ """
339
+ return self ._bom_ref
340
+
302
341
@property
303
342
@serializable .xml_sequence (10 )
304
343
@serializable .xml_string (serializable .XmlStringSerializationType .NORMALIZED_STRING )
@@ -367,7 +406,8 @@ def contacts(self, contacts: Iterable[OrganizationalContact]) -> None:
367
406
368
407
def __comparable_tuple (self ) -> _ComparableTuple :
369
408
return _ComparableTuple ((
370
- self .name , _ComparableTuple (self .urls ), _ComparableTuple (self .contacts )
409
+ self .name , _ComparableTuple (self .urls ), _ComparableTuple (self .contacts ),
410
+ self ._bom_ref .value ,
371
411
))
372
412
373
413
def __eq__ (self , other : object ) -> bool :
0 commit comments