Skip to content

Commit

Permalink
adapter.http: simplify SubmodelElement deletion
Browse files Browse the repository at this point in the history
We can always call `_get_submodel_or_nested_submodel_element`, as it
returns the submodel itself if we don't pass it any id_shorts.
  • Loading branch information
jkhsjdhjs committed Mar 15, 2024
1 parent 107f158 commit ae8d527
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions basyx/aas/adapter/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,10 @@ def delete_submodel_submodel_elements_id_short_path(self, request: Request, url_
submodel = self._get_obj_ts(url_args["submodel_id"], model.Submodel)
submodel.update()
id_short_path: List[str] = url_args["id_shorts"]
parent: model.UniqueIdShortNamespace = submodel
if len(id_short_path) > 1:
parent = self._expect_namespace(
self._get_nested_submodel_element(submodel, id_short_path[:-1]),
id_short_path[-1]
)
parent: model.UniqueIdShortNamespace = self._expect_namespace(
self._get_submodel_or_nested_submodel_element(submodel, id_short_path[:-1]),
id_short_path[-1]
)
self._namespace_submodel_element_op(parent, parent.remove_referable, id_short_path[-1])
return response_t()

Expand Down

0 comments on commit ae8d527

Please sign in to comment.