From 6ea9f37a046797dc61c2ebd84a88ba5b7a9f05f3 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Fri, 11 Mar 2022 13:56:27 +0100 Subject: [PATCH] Revert "FIX: problem in old apiutils sub function with recursion variable" This reverts commit 2f216cef894179951e9f94d342762e45d85ec3e6. --- src/caosdb/apiutils.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/caosdb/apiutils.py b/src/caosdb/apiutils.py index dbab28f9..a8256976 100644 --- a/src/caosdb/apiutils.py +++ b/src/caosdb/apiutils.py @@ -381,10 +381,7 @@ def _single_convert_to_python_object(robj, entity): return robj -def _single_convert_to_entity(entity, robj, recursive_depth, **kwargs): - """ - recursive_depth: disabled if 0 - """ +def _single_convert_to_entity(entity, robj, **kwargs): if robj._id is not None: entity.id = robj._id @@ -410,16 +407,16 @@ def _single_convert_to_entity(entity, robj, recursive_depth, **kwargs): else: entity.add_parent(id=parent) - def add_property(entity, prop, name, _recursive=False, datatype=None): + def add_property(entity, prop, name, recursive=False, datatype=None): if datatype is None: - raise RuntimeError("Datatype must not be None.") + raise ArgumentError("datatype must not be None") if isinstance(prop, CaosDBPythonEntity): entity.add_property(name=name, value=str( prop._id), datatype=datatype) - if _recursive and not prop.do_not_expand: - return convert_to_entity(prop, recursive=_recursive) + if recursive and not prop.do_not_expand: + return convert_to_entity(prop, recursive=recursive) else: return [] else: @@ -429,11 +426,6 @@ def _single_convert_to_entity(entity, robj, recursive_depth, **kwargs): return [] - if recursive_depth == 0: - recursive = False - else: - recursive = True - for prop in robj._properties: value = robj.__getattribute__(prop) @@ -447,7 +439,7 @@ def _single_convert_to_entity(entity, robj, recursive_depth, **kwargs): if recursive and not v.do_not_expand: children.append(convert_to_entity( - v, recursive=recursive_depth-1)) + v, recursive=recursive)) else: if isinstance(v, float) or isinstance(v, int): lst.append(str(v)) -- GitLab