From 904d7a521e6fc8fbfc98525704391379f830fdbb Mon Sep 17 00:00:00 2001 From: Florian Spreckelsen <florian.spreckelsen@gmx.net> Date: Mon, 29 Jun 2020 12:44:07 +0000 Subject: [PATCH] F doc get parent --- src/caosdb/common/models.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 5ab31f48..adbd9dc3 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -517,6 +517,22 @@ class Entity(object): w_parent._get_parent_recursively(all_parents) def get_parent(self, key): + """Return the first parent matching the key or None if no match exists. + + Parameters + --------- + key : int or Enity or str + The id, Entity, or name of the parent that should be + returned. If an Entity is given, its id or its name is + used to find a matching parent. + + Returns + ------- + parent : Entity + The first parent of this entity that matches the given id, + entity, or name. + + """ if isinstance(key, int): for p in self.parents: if p.id is not None and int(p.id) == int(key): @@ -2780,7 +2796,8 @@ class Container(list): for f in listdir(x): if isdir(x + '/' + f): - part = MultipartParam(name=hex(randint(0, sys.maxsize)), value="") + part = MultipartParam( + name=hex(randint(0, sys.maxsize)), value="") part.filename = upload + \ ('/' + d + '/' if d is not None else '/') + f + '/' ret.extend(Container._dir_to_http_parts( -- GitLab