From ae8d5276a5fcbd43295e838692742563ac4c62bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20M=C3=B6ller?= Date: Fri, 15 Mar 2024 19:01:33 +0100 Subject: [PATCH] adapter.http: simplify `SubmodelElement` deletion 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. --- basyx/aas/adapter/http.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/basyx/aas/adapter/http.py b/basyx/aas/adapter/http.py index e55fddff3..468e5deb0 100644 --- a/basyx/aas/adapter/http.py +++ b/basyx/aas/adapter/http.py @@ -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()