Skip to content
Open
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
9 changes: 6 additions & 3 deletions sdk/basyx/aas/adapter/json/json_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ def _construct_value_list(cls, dct: Dict[str, object]) -> model.ValueList:
def _construct_value_reference_pair(cls, dct: Dict[str, object],
object_class=model.ValueReferencePair) -> model.ValueReferencePair:
return object_class(value=_get_ts(dct, 'value', str),
value_id=cls._construct_reference(_get_ts(dct, 'valueId', dict)))
value_id=cls._construct_reference(_get_ts(dct, 'valueId', dict))
if 'valueId' in dct else None)

# #############################################################################
# Direct Constructor Methods (for classes with `modelType`) starting from here
Expand Down Expand Up @@ -692,18 +693,20 @@ def _construct_submodel_element_list(cls, dct: Dict[str, object], object_class=m

@classmethod
def _construct_blob(cls, dct: Dict[str, object], object_class=model.Blob) -> model.Blob:
content_type = _get_ts(dct, "contentType", str) if 'contentType' in dct else None
ret = object_class(id_short=None,
content_type=_get_ts(dct, "contentType", str))
content_type=content_type)
cls._amend_abstract_attributes(ret, dct)
if 'value' in dct:
ret.value = base64.b64decode(_get_ts(dct, 'value', str))
return ret

@classmethod
def _construct_file(cls, dct: Dict[str, object], object_class=model.File) -> model.File:
content_type = _get_ts(dct, "contentType", str) if 'contentType' in dct else None
ret = object_class(id_short=None,
value=None,
content_type=_get_ts(dct, "contentType", str))
content_type=content_type)
cls._amend_abstract_attributes(ret, dct)
if 'value' in dct and dct['value'] is not None:
ret.value = _get_ts(dct, 'value', str)
Expand Down
8 changes: 5 additions & 3 deletions sdk/basyx/aas/adapter/xml/xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def construct_basic_event_element(cls, element: etree._Element, object_class=mod
def construct_blob(cls, element: etree._Element, object_class=model.Blob, **_kwargs: Any) -> model.Blob:
blob = object_class(
None,
_child_text_mandatory(element, NS_AAS + "contentType")
_get_text_or_none(element.find(NS_AAS + "contentType"))
)
value = _get_text_or_none(element.find(NS_AAS + "value"))
if value is not None:
Expand Down Expand Up @@ -851,7 +851,7 @@ def construct_entity(cls, element: etree._Element, object_class=model.Entity, **
def construct_file(cls, element: etree._Element, object_class=model.File, **_kwargs: Any) -> model.File:
file = object_class(
None,
_child_text_mandatory(element, NS_AAS + "contentType")
_get_text_or_none(element.find(NS_AAS + "contentType"))
)
value = _get_text_or_none(element.find(NS_AAS + "value"))
if value is not None:
Expand Down Expand Up @@ -1063,8 +1063,10 @@ def construct_submodel(cls, element: etree._Element, object_class=model.Submodel
@classmethod
def construct_value_reference_pair(cls, element: etree._Element, object_class=model.ValueReferencePair,
**_kwargs: Any) -> model.ValueReferencePair:
value_id_element = element.find(NS_AAS + "valueId")
value_id = cls.construct_reference(value_id_element, **_kwargs) if value_id_element is not None else None
return object_class(_child_text_mandatory(element, NS_AAS + "value"),
_child_construct_mandatory(element, NS_AAS + "valueId", cls.construct_reference))
value_id)

@classmethod
def construct_value_list(cls, element: etree._Element, **_kwargs: Any) -> model.ValueList:
Expand Down
Loading